Before updating to Windows 10 you may need to return your Pro license. More information here

App Crashing on iPhone due to Texture Memory

I've got about 1000 textures in my app, a few hundred of which are active / loaded at a given time. The app I'm running runs ok on an iPhone 4S and the iPad (first gen), but crashes with memory warnings and then app crashes on initial load on the older iOS devices (iPod 2nd gen, iPhone 3, etc.).

I've run the app on the device with the Unity Profiler, but that only tells me the total memory used (41.2MB including 20.9 in Textures and 16.3 in Meshes). It won't tell me which textures are taking up the most space.

I'm trying to find all of the active textures and the memory they're using. Here is the code I've tried:

         var textures = Resources.FindObjectsOfTypeAll(typeof(Texture2D));
         for (var t : Texture2D in textures) 
             Debug.Log("Texture object " + t.name + t.width + "x" + t.height + " (" + t.format + ") using: " + Profiler.GetRuntimeMemorySize(t) + "Bytes");

This finds all of the textures being used in Unity Editor (Game mode), including all of Unity's assets which doesnt really help me. And, this code won't build to the device because GetRuntimeMemorySize doesn't seem to be accessible on the device. Here's the error:

Assets/Scripts/mainmenugui.js(1121,123): BCE0019: 'GetRuntimeMemorySize' is not a member of 'UnityEngine.Profiler'.

Any ideas on how I can get a full readout of all of the active / in use textures and their memory usage on the device while it's running? Also, not sure how to output to the console in XCode.

Any ideas??

more ▼

asked Mar 04, 2012 at 02:03 AM

avatar image

2 9 6 8

"Assets/Scripts/mainmenugui.js(1121,123): BCE0019: 'GetRuntimeMemorySize' is not a member of 'UnityEngine.Profiler'." was fixed in Unity 3.5.1.

Apr 19, 2012 at 01:07 PM Mantas Puida
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

I don't know how helpful it would be, but have you checked out the Editor Log?

more ▼

answered Apr 19, 2012 at 02:13 PM

avatar image

180 50 46 64

(comments are locked)
10|3000 characters needed characters left

Thanks Helios. I did check the Editor Log and it helped a bit. It showed me everything that's loaded in the editor and from there I guessed at what was running on the device. I didn't realize that some fonts take up a ton of memory and it helped me find some other textures that were eating up space.

more ▼

answered Apr 22, 2012 at 02:50 AM

avatar image

2 9 6 8

(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



Answers and Comments



asked: Mar 04, 2012 at 02:03 AM

Seen: 2463 times

Last Updated: Apr 22, 2012 at 02:50 AM