- Home /
Memory leak gallore
Note: I've also openend a topic on the forum about this: http://forum.unity3d.com/threads/111365-Memory-leak-galore **
Note2: Please vote! http://feedback.unity3d.com/forums/15792-unity/suggestions/1067023-scripting-garbage-collection-sgen-gc **
At our company we have several projects relying heavily on Unity. We used all the tricks out there (http://answers.unity3d.com/questions/129364/memory-management-tips.html), but somehow when we close our webplayer, one title still has 150 MB and another has 200 MB of unreleased memory (both in Firefox and Chrome). What is worse, is that when you start a new game, without killing the previous plugin container, it simply adds to this memory residue, so it's not a question of caching. The editor too, appears to have this problem.
Now, of course, you can accuse us of bad programming. Sure. We're the worst programmers ever. However, it cannot be that the virtual machine does not release the memory claimed by our games, anno 2011. So my question is twofold:
Do other developers recognize any of this?
When is Unity3D going to upgrade its version of Mono? (and don't say it's too ingrained in Unity, that's what design patterns are for)
http://tirania.org/blog/archive/2009/Nov-09.html
Sorry for the tone, but something needs to be done, since 3.5, at the moment, doesn't hint at any improvement in this area.
ps: Starting the game again and closing it adds 150 or 200 mb respectively, so the residue increases 150, 300, 450 etc. And remember that users have more than 1 tab open, so machines start swapping rather fast. pps: Another thing we've looked at http://answers.unity3d.com/questions/153050/memory-management-and-list.html
I've ranted about this issue on several occasions myself and can only +1 the question. It's hard to answer your question because this board is user driven, and the fellow users don't know what Unity Technology's plans are for $$anonymous$$ono. $$anonymous$$now, though, that I too recognize this, and really badly want a generational garbage collector.
Yes, I'm well aware of http://answers.unity3d.com/questions/153050/memory-management-and-list.html :)
I wrote that question.
LOL :) Sorry, I didn't look at the name. Btw, have you ever encountered the 'Too many heap sections' message, after which Unity crashes?
Yes. That's the "standard" message Unity throws at me when it runs out of memory. It makes good sense too - the heap is where all declared variables, global variables, static variables etc is declared (as opposed to the stack, which houses local variables such as those declared within a function or passed as parameters). The stack cannot get fragmented, because memory allocated to it is popped off of it again in the proper order; it obeys the LIFO principle. It's like adding and removing plates in a kitchen cubboard - no holes appear in between plates, because the one most recently added is also the one that will next be taken. That's why it's called "the stack". The heap is different: It obeys no principle that maintains non-fragmentation. When memory is de-allocated and the garbage collector fails to properly defragment the heap, huge holes appear in it, and in the end, the OS refuses to offer up more fresh memory, so Unity is unable to expand its heap. Then it crashes with the "too many heap sections" message.
Exactly. It's the problem addressed in the blog post by $$anonymous$$iguel de Icaza ($$anonymous$$ono's lead developer at the time). Note how the blog post is from 2009.....
Answer by ptdnet · Nov 27, 2011 at 05:37 PM
For what it's worth I went to the Mono web site and installed their latest version. It works perfectly with Unity.
That sounds very interesting ptdnet. Do you believe that that version of $$anonymous$$ono is then also used for building a webplayer?
I was under the impression the $$anonymous$$ono runtime was somehow kneaded so deeply into Unity that you couldn't just update it yourself manually. Are you certain Unity is actually using what you installed, and not just continuing on with its own?
Yes, after drinking my first coffee and discussing this with colleagues, we have the same question as Christian. Seems to us that you at least had to exchange some dll in the Unity directory, but from your comment it sounds as if it works 'out of the box'. Can you give us some more specifics? :)
It's using the only version of $$anonymous$$ono on my computer (v2.8.1). I'm using Snow Leopard.
I'm almost 100% you're not running your own installation of mono. Please take a look at these links:
http://answers.unity3d.com/questions/8067/will-installing-a-newer-mono-version-break-unitys.html
And in particular, HiggyB's reply in the forum one. You cannot simply replace Unity's version of $$anonymous$$ono yourself, it's integrated into the system, as explained. What you have installed is running alongside Unity's own version, not ins$$anonymous$$d of Unity's own version, and Unity's version will not change unless Unity Technology decides to change it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613035904im_/https://answers.unity.com/themes/thub/images/avi.jpg)