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?

1 Like

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.

Check out a memory tab in profiler

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 :

  1. Open Profiler disable “Record” and enable “Profile Editor” (also clear sample data if there is any).
  2. Open up editor windows that I normally use.
  3. Hit “Record” button and start taking sample. (keep an eye on your memory, those sample data could take a lot of your memory)
  4. End “Record” before memory ran out.
  5. Close all unity window but the profiler.
  6. Select a frame on Memory section and change mode from “Simple” to “Detailed”.
  7. 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.

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 minutes 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.

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.

Same issue with a large memory leak when updated to 2017 (free version). Gigs of memory in a few minutes.