So I’m developing a project for the iPhone for about 5 months now. We tested our build on an iTouch 4th gen device sometime in September and we were getting around 80MB in memory usage. Today, we’re getting around 120MB, which inevitably crashes. We got this information from Xcode>Instruments>Activity Monitor.
Now, we connected this up to the AutoConnect profiler to check out what memory allocation was. After adding up all memory numbers (Total, Textures, Meshes, Materials, etc) we reached a lower number. Nearly every time, it would be a discrepancy of about 40MB (once, 36MB).
We’ve been racking our brain to no avail as to the cause. I removed all textures from one scene and the memory usage went down 10MB in both profilers. The number of changes between here and a month ago are pretty big, so removing them one by one isn’t an option. Anyways…Here’s my questions:
Is there any way to find out what is allocating that space?
Is there any common culprits of this sort of memory allocation? Garbage Collection? using System.DateTime; or something?
Oh, one thing to note is that we Load to a completely blank scene and asynchronously load levels after that. Oddly enough, in the editor, profiler reveals that I have used 13MB even before the other levels load. Loading to a blank scene should clean memory, correct?
loading a blank scene should clean memory, yes. But it can not clean or touch the memory required to load and maintain the application code in memory which on iOS is a must (on mobile in general) as they have no paging. Either it fits into ram or gets killed.
I’m definitely not asking if our game is clearing out iOS memory to fit our 120MB size. I’m wondering if our game should really be 120MB.
The way I counted metrics was to start with what Instruments provided, which was 123.7MB.
Now, the AutoConnect Profiler gave us something like the following information:
Adding all these numbers up totals to about 84 MB. So there’s around 40 MB discrepancy between Instruments AutoConnect Profiler in Unity.
Is this normal? or even accurate method? Is there an accurate method?
I ran a Debug line that spit out Profiler.usedHeapSize System.GC.GetTotalMemory() so I could see what Unity Mono was using.
Mono went from around 500,000 to 1,200,000. It would go up up from around the 500k mark to the 1.2m mark, then fall down again.
Unity was around 20-30 million depending on the scene. Again, this doesn’t seem to match the Instruments Activity monitor reading of 110-120MB per scene load.
We’re at wits end on how to solve this memory crisis. Anybody have any ideas?