Memory Leaks?

Using the latest beta on PC Desktop and it seems to eat ram compared to previous beta.
When I open my working project I have about ~50% ram used on an 8gb system.

After a few runs of scenes in the editor it gradually maxes out the ram and kills my system.

Any clues?
Is there any way to restrict Unity editor to use a maximum amount of ram?


I found a memory leak in 2017.1 beta that occurs when you search in the Hierarchy:

I don't know whether this has been fixed in 2017.2 already. Perhaps you ran into the same issue?


No, this is different I think. I wasn't searching afaik. I'm not sure what the trigger is for this, but it seems to occur after playing a scene a few times. Maybe a leak when running, but not getting released on stop?

In addition to this memory hogging leak the new package manager spooling up a node.js server is also consuming more resources. This is a good idea to be on by default, there should be some option to turn these components on and off by request. This is important when developing on systems that need ram. Not every one has a 32gb ram top of the line machine.

Previously I've never had problems running unity editor, Visual Studio, and a browser open.
Now I'm getting my memory eaten like crazy and it's really impacting development.

I've discovered what the problem is that's causing it.

It's something to do with the UI.
Initially I thought it only occurred when I showed my UI in play mode (via the space bar), as every time I did I could see the windows task manager memory start growing for Unity.exe

But I just discovered it also happens in normal editor mode, no doubt due to Unity's preview mode.
I had my UI panels up and was editing them and noticed the Ram was going through the roof.

This is a showstopper. Surely others are noticing this?

Pretty certain this is b2 related as I don't recall such issues with b1.

Ah, I think I know which bug that is.

From talking with the team, it's UI Profiler specific and not a normal runtime issue. (Obviously that interferes with profiling though). A fix is in-progress in landing and getting to 2017.2.

Thanks for the update. Looking forward to the fix!

It says "Fixed in Unity 2017.1" but I'm using Unity 2017.2.0b2 and it's in that.
I submitted a bug report (Case 928496) Unity2017 b2 Ram Eater

1 factor is to blame the engine, 2. factor is to check your own codes for allocation. Are you allocating in update etc?

Our "Fix" means it's fixed in development, but not yet pushed and verified to a release branch.
The in-version is just the where it was logged against and targeting to fix.

It's actually also not landed to 2017.1 either, it's in a dev branch on way to 2017.1.
While we do our best to avoid the latency of having a fix put everywhere, there is some gap in making sure it's in all places.

@anon_68127303 Thanks for the clarification

@Ironmax Initially I thought the problem may be caused by a UI package I was using (!/content/54552) but after I refactored and removed it I noticed the Ram getting eaten while I was editing the normal UI. I wasn't in play mode and it's just a test harness UI with sliders etc for rapid prototyping settings changes when in full screen (instead of using editor inspector), nothing fancy.

Not sure if this is Editor only or not. but "Canvas.SendWillRenderCanvases" is allocating allot of memory. You can try to remove pixel perfect on your canvas and see if that fixed your issue.

Nope, no effect.

Canvas system in Unity have been leaky for some time now since it was introduced.

Try System.GC.Collect(); some where in your code to see if it changes any thing.

lets say after 2 min.

Sounds a bit hacky.

Unity QA just sent me an email as per Alex's explanation saying it was a duplicate of and a fix is coming soon.

yes its hacky, but its just to check if the leak comes from your own codes or the engine.

But yeah its good they are adressing this.

this issue it not only releted to Text.text set. also icon sprite change, or color change.
basically any UI component..

There is no way for managed-side regular allocations to cause what he is seeing, the collector will trigger automatically when enough allocations have occurred, long before he ends up with his entire system running out of memory. His code could potentially allocate unmanaged objects or trigger the allocation of them, but GC.Collect() would have no effect whatsoever in that case. Resources.UnloadUnusedAssets() might but since Unity have confirmed this as a bug, I'd just wait.

Managed code can cause leak, because the collector waits before it collects (specially the new one). But i agree in his case its highly unlikely. Lets just hope we get this fixed soon, canvas is the only thing i have issue with when it comes to memory.

Anyone finding when "upgrading" importing project the CPU (MacOSX) goes crazy.. not a memory leak directly but I think it can be related, some optimisation on Unity and harmony with the OS is needed.

I'm also having this problem, on the release version of 2017.1.

The editor once killed my laptop each time I preview my project.

I hope there's a solution for this.

So, I've reverted to 5.6, although lost some new features. No memory leaks so far.

So, it could be a bug in 2017.1 that's causing the memory leak.

I hope it will be fixed ASAP.

1 Like

We'll need a bug report for that.