how to detect unity engine memory leak?

I've already check the total objects in memory, it's same,but the total memory still increase.

it's happened at my switch two levels by LoadLevel.

It seems that when your memory is on the edge, and you request the memory by requesting level load. If it is possible for you First destroy the objects in current scene and then load new level.


Which platform? If on iOS, I found that loadLevel do not release assets properly for the garbage collector to to its work when needed, and in the troubleshooting page, they mentionned loadLevelAdditive as an alternative and it works reliably.

1- load an empty scene using loadLevel() ( a special scene with nothing in it) 2- load your actual scene additively using LoadLevelAdditive() 3- I just call UnloadUnusedAssets just to force things. it might not be required tho.

in effect, this equal loadLevel(), but now, the app is 100% stable and I don't get any memory warnings like when just using loadLevel() only.

It could be a solution for other platforms too.

Hope it helps,



Thank you very much! I'll try it next week, it's so smart!

Oh, i tryed this methods. my project run in webplayer, the leaks are still at there.

my project has ye share assets between two levels. i think somewhere has bug in share assets.

first, i build a loader.uniy3d, then, i use a Don't Destroyed Objects between in two levels. then, i hold the two levels WWW handles in the Don't Destroyed Objects. I wan't store some values in shared object with two levels.