- Home /
Unity Editor Memory Leak
I've recently come across an issue that is extremely puzzling (and really a project stopper). Basically, When I press play in the editor, and then press stop, unity eats up a bit of my memory, and refuses to give it back (I discovered this when my mac kept running out of memory). In my main project, it eats about half a gig on every iteration (Obviously a real problem). I started removing code and objects from my project, to no avail. Eventually I just started a new empty project (even removing the camera and the light), and lo and behold, same problem. Not half a gig (more on the order 20 meg), but still a leak. I don't know what this could be. Here are some facts to note:
I recently upgraded to Unity 2017
I'm working on a macbook pro with 16 GB memory
In the activity monitor, the total memory used goes up on every iteration of play/stop, but the Unity process memory does not. In fact, I can't find the process using the extra memory.
I frequently have multiple instances of Unity running, and communicating with each other via UNET. However, the empty project running with no other instances open still leaked.
When I put the computer to sleep, one of two things will happen: either a unity instance will crash, or a significant amount of memory will be freed up (approximately half of the memory eaten up by starting and stopping unity)
Does anybody have any idea what this could be? Has anyone experienced something similar? If this is a Unity bug how would I go about informing the correct people / avoiding the problem? If I did something wrong, what should I change?
I switched to a PC and that seems to have solved my problems for now.
We are experiencing a massive memory leak issue -- it frequently crashes both of our development PCs and seems to be particle related. Right before the comps go down they get an Assertion Failed in console, and the following crash usually requires a hard reset. It happens in editor when viewing particle effects, even when the game is not running. Builds of the game work fine. We can't work on our project for more than 20 $$anonymous$$utes at a time, and when at full clip, Unity eats up 100 megs of memory a second.
Please get this fixed asap. This is absolutely ridiculous that this type of error made it out the door in core release.
Same issue with a large memory leak when updated to 2017 (free version). Gigs of memory in a few $$anonymous$$utes.
Answer by PNUMIA-Rob · Aug 09, 2017 at 02:25 AM
We are also experiencing is (or a very similar) issue after updating to Unity 2017 when programmatically setting the effectColor property of a Outline/Shadow component.
GetComponent<Outline>().effectColor = Color.black;
With 20 items doing this on a regular basis, several gigs of RAM is eaten up in a matter of minutes and a full OOM error and possible device crash eventually always occurs.
Update:
Not sure this is anyone else's issue, but ours ended up being that one of the $$anonymous$$m members had set Build Settings -> Other Settings -> Scripting Runtime Version to Experimental (.NET 4.6 Equivalent) and forgot to disable it before committing. Switching it back to Stable (.NET 3.5 Equivalent) plugged the leaks.
Hope this helps someone.
Cheers!
Answer by LocalNoob · Aug 01, 2017 at 04:54 PM
Check out a memory tab in profiler
Unfortunately, I have the free version of unity, so the profiler is unavailable to me.
At the top panel go to window-profiler. I also got a free version and it is available
Ok, I can bring it up but I'm not sure how to interpret it. It runs even when not in play mode (as expected). Right now I'm using 13.3 GB out of 16 GB with one unity instance running. What information should I be trying to obtain from the profiler?
Answer by x4637x · Aug 04, 2017 at 06:28 AM
I also have the same problem currently, but I am using both Windows and Linux. Wired thing is Unity running on Linux perfectly fine (no leak), only Windows have this issue.
What I been trying to solve this is find out detail memory usage in unity profiler, so far I am using profiler like this :
Open Profiler disable "Record" and enable "Profile Editor" (also clear sample data if there is any).
Open up editor windows that I normally use.
Hit "Record" button and start taking sample. (keep an eye on your memory, those sample data could take a lot of your memory)
End "Record" before memory ran out.
Close all unity window but the profiler.
Select a frame on Memory section and change mode from "Simple" to "Detailed".
After in "Detailed" mode, click "Take sample : Editor".
The last step is the close I can get to the source right now, still trying to work out what is the cause from there. I hope this information is useful for your debugging as well.
So far I'm not having an issue on windows, but I've only been using it for a day. I'll let you know if that changes.
Update : We've fixed our leak. It's cause by our own editor code, one of our editor tool create lots of Icon Texture2D during Update. Fixing that have stop the leaking. We figured this out by looking into Unity profiler and noticed GUIRepaintAll() is taking too much resources. Also Texture count in memory is increasing way too fast. If anyone having trouble looking into profiler data at the same project, I suggest you save your profiler recorded data to somewhere first, then load it in an empty project and then analysis it there.
Answer by ralphyua_unity · Sep 30, 2017 at 02:47 AM
When is Unity going to fix this? Having the same problem where Unity will crash after running out of memory. This didn't happen until I upgraded to the latest release of Unity. I can only work for about twenty minutes before I have to restart again. It's a real pain in the butt. I try to save after every little change knowing that the clock is ticking and that the memory could be used up at any time. When I open a new project, Unity then deallocates the memory, but that doesn't really solve anything. Quitting and restarting Unity is better than going into a new project then the original project again.
This is not an answer. This is a Q&A site. One question at the top and answers which answer the question below. If you can't answer the question, don't post an answer. You can post a comment if you think you actually have to say something new. If not please don't bump threads for no reason. Unity staff won't read the questions here. If you want to file a bug report you should do that from within Unity.
However first make sure you actually read all the information available here. Especially "LucidAmusement" answer and his comment on his answer. So make sure you don't use the "Experimental" backend.
ps: You haven't mentioned which exact version you're using "latest release" can be interpreted in many ways as Unity has an official stable release, temporary patch releases and beta / experimental releases.
Your answer
Follow this Question
Related Questions
Memory Leak in Play Mode 1 Answer
Is this memory usage too much for a mobile game? 1 Answer
iOS crash problem: Received memory warning . How to solve that? 1 Answer
Question About Camera's, Canvases and Memory 0 Answers
"Real Memory" usage in iOS expands the more often one prefab is referenced in the assetbundle 0 Answers