- Home /
Memory Issues in Unity for Android and IOS
I'm working on a project that uses lots of GUIs and WWW. The issues with memory involving the www were all resolved thanks to the author of this question.
But we're still having issues with memory allocation. We double checked our scenes and scripts and found nothing unusual, and when run in the editor shows no memory problem.
But when we play the game on mobile devices the memory usage keep growing and growing until the app crashes.We tought it could be memory leaks from the textures and/or objects. But i discarded that after some texts in empty scenes with our scripts.
We found that by forcing the System.GC.Collect() in some momments of our code would release some of the allocated memory. But that would only buy us some time until the application crashes again.
We're using unity 3.5.0f5 and our App consumes about 80MB of real memory in the profiler of the xCode, and I'd like to know if someone with similar issues solved his/her problem, and how :/
yes, we call it every now and then, usually after ending a match or unloading lots of textures.
So another idea - are you using any kind of dictionary or list that stores references or uses keys that are GameObjects, assets, Components etc?
Ok so you can end up eating your memory that way if you aren't careful - it's the easiest way in the world to have a hard to find memory leak.
If it's in plug ins then make sure that only sensible values are kept - if you are doing it yourself then consider something like this which doesn't hold a strong reference.
Answer by Jeffom · Jun 25, 2012 at 07:10 PM
Found the answer in this post
http://answers.unity3d.com/questions/7836/preloading-caching-prefabs-unity-iphone.html
seems like
GameObject newObject = someReference;
GameObject.Destroy( new Object );
newObject = new GameObject();
flags the unity to release the memory alocated by the previous object, and my problem was not doing this with my texture objects (1024x1024) problem solved after adding this to my codes.
Your answer
Follow this Question
Related Questions
Help when playing in Editor , Big memory Leak/problem 0 Answers
iOS Memory Handling Crash on Startup 0 Answers
Laggy gameplay and occasional crashes 1 Answer
Editor crash after editing in a better computer 0 Answers
Crash from texture memory? 2 Answers