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:
#if ENABLE_PROFILER
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");
}
#endif
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??