So how much memory is my iOS game using?

I’ve got three numbers that don’t match between XCode “Allocations”, “Memory Monitor” and the new detailed view Unity Profiler.

Unity profile says I’m using 99MB of memory
XCode Allocations says 131MB
XCode Memory Monitor says 232MB

I’m guessing the latter is right, because I start getting allocation warnings when it goes above 250MB and am killed shortly afterwards (on an iPad2).

So how am I meant to work out what is using what? What do I multiply my Unity detailed profiler readings by to get an accurate picture?

I’ve tried multiplying Texture and Meshes by 2 - this gives 150MB, but clearly multiplying the whole thing by 2 wouldn’t give me the reading of Memory Monitor.

What techniques can I use?

Details about the app:

  • Vuforia plugin
  • Scaleform plugin
  • Scene has around 8000 tris, 3 skinned mesh renderers, everything else static.
  • 2 cameras (1 for reflection texture, this is a dressing room).

I’ve spent a bit of time looking into this in the past; the Unity profiler provides memory info on assets loaded into the game, but unfortunately it isn’t a complete picture of memory being used.

The XCode memory monitor is certainly the most accurate value, and also the one that really matters; it is an accurate indicator of when you will start seeing memory warning and ultimately an app crash.

Also, FWIW, I’m under the impression that there are three areas in Unity that use memory: managed heap, native heap, and the app code. Managed heap is stuff allocated in script, native heap is mainly assets, and app code is all the code and DLLs. The app code can actually bite you pretty hard. Unity by itself is a good chunk of memory (8-14MB I think) and then any DLLs or code associated with Vuforia or Scaleform might be pretty heavy as well. App code is pretty much always in memory; loaded up on app start and stays until it closes.

Anyway, as I said, I’ve spent some time working through Unity’s memory puzzle, but I’m certainly not an expert - so if any of the above sounds wrong, please correct me!