x


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 :/

more ▼

asked Jun 13 '12 at 07:22 PM

Jeffom gravatar image

Jeffom
213 2 3 10

Have you tried using Resources.UnloadUnusedAssets?

Jun 14 '12 at 04:08 PM whydoidoit

yes, we call it every now and then, usually after ending a match or unloading lots of textures.

Jun 14 '12 at 04:47 PM Jeffom

So another idea - are you using any kind of dictionary or list that stores references or uses keys that are GameObjects, assets, Components etc?

Jun 14 '12 at 04:55 PM whydoidoit

actually yes we are, but mostly through plugins.

Jun 14 '12 at 05:04 PM Jeffom

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.

Jun 14 '12 at 05:07 PM whydoidoit
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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 );
new Object = 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.

more ▼

answered Jun 25 '12 at 07:10 PM

Jeffom gravatar image

Jeffom
213 2 3 10

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x592
x328
x32

asked: Jun 13 '12 at 07:22 PM

Seen: 2328 times

Last Updated: Jun 25 '12 at 07:40 PM