Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by LCay · Nov 06, 2015 at 02:23 PM · memory-leakleakheadless

Ubuntu linux, Headless mode ,Memory Leak!! why?

hi,I need some help . I write a physicalServer used unity3d and run it on linux platform , and with "headless" mode, then the memory raise up to 3.5 GB quickly ! then I try run a noraml version without "headless", 24h has past and the memory stay between 300MB --- 350MB(no memory leak). So, who knows why the memory leak under "headless mode" ? how can I to improve ? thank you

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MariuszKowalczyk · Nov 17, 2016 at 08:40 PM 0
Share

Looks like executing Resources.UnloadUnusedAssets() from time to time helps. But I have also made some other changes so I am not sure at the moment if this is the key point.

I have also added this piece of code to run from time to time:

         var textures : Texture[] = Resources.FindObjectsOfTypeAll(Texture);
 
         for (var i = 0; i < textures.length; i++)
         {
             //Debug.Log(textures[i].name + " __ " + textures[i].hideFlags);
 
             if (textures[i].hideFlags == HideFlags.NotEditable ||
                 (textures[i].hideFlags == HideFlags.None && textures[i].name != "")
                )
             {
                 //Debug.Log(textures[i].name + " __ " + textures[i].hideFlags);
 
                 Resources.UnloadAsset(textures[i]);
 
                 textures[i] = null;
             }
         }

And the last thing I did, was to avoid String addition, because it allocates memory. It's better to use System.Text.StringBuilder.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by robertono · Jan 07, 2016 at 10:12 PM

Maybe there is shader or any graphycs on scene, whose causing memory leak ?

Two months passed.. Have you solved the problem?

I'm just going to host unity server on ubuntu using "headless" mode, so that's why im interested.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image LCay · Jan 08, 2016 at 08:33 AM 0
Share

@robertono In actually I found the key point but I can not solve the problem whaterver you have anything need to render or not ,you must keep a camera in scene under headless mode

avatar image MariuszKowalczyk LCay · Jan 09, 2016 at 09:49 AM 0
Share

So when you add the camera to the scene, the memory leak disappears? (I have this problem too).

avatar image robertono MariuszKowalczyk · Jan 09, 2016 at 03:52 PM 0
Share

No, he says that he always has a camera, but in the normal mode (without argument "headless") app works O$$anonymous$$, without any memory leak (as I understood).

avatar image robertono LCay · Jan 09, 2016 at 03:53 PM 0
Share

You need to post this bug to the issue tracker, I think. I would vote for it

avatar image
0

Answer by MariuszKowalczyk · Jan 11, 2016 at 07:19 PM

Removing all OnGUI() functions from the code solved this problem for me. Not only the inside of the function, remove the whole function. You can use the following method:

 #if IS_DEDICATED
 function OnGUI()
 {
 }
 #endif

Then you have to define IS_DEDICATED in ProjectSettings>Player>Scripting Define Symbols.

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MariuszKowalczyk · Jan 11, 2016 at 07:49 PM 0
Share

It helped, but I still have this problem.

avatar image MariuszKowalczyk · Jan 12, 2016 at 09:25 AM 0
Share

Hmm. I start to suspect, that this is not actually a bug. As you know, it takes time for the garbage collector to run. So if the memory is not needed by other applications, then there is no point to run the garbage collector. And maybe this is the purpose of the memory increase.

Like I said, just "maybe". And another "maybe": maybe to fix this "issue" you just need to run garbage collector by yourself when the server is for example empty.

Anyway, these above are just my free thoughts, I will verify them soon. And I think like I am wrong and there is actually a bug.

You should avoid allocating memory during the game. In my case the increase is due to allocating when new player connect to the server and destroy when he is gone. It may also be due to other operations that allocate memory like string addition etc. I am sure, because I have tested. When the server is with password and no one can connect, there is no memory growth. I have just made a fix to this and will tell you if it helped.

To avoid string addition use: System.Text.StringBuilder $$anonymous$$ore info here: http://docs.unity3d.com/$$anonymous$$anual/UnderstandingAutomatic$$anonymous$$emory$$anonymous$$anagement.html

If you want to see Unity Legacy Networking with Dedicated Servers in action, I invite to my game Ball 3D (www.ball3d.com).

avatar image robertono MariuszKowalczyk · Jul 01, 2016 at 01:48 PM 0
Share

Hello Any updates on this ? Have you checked by yourself ? Whats the results ?

Thanks

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Performance going down over time 2 Answers

Mesh memory leak 3 Answers

Mesh Destroy After an Editor Stop 0 Answers

m_Memory.renderTextureBytes<0 1 Answer

Memory Leak Help 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges