Best Practices For Tracking Memory Allocations In IOS

So far, we’ve been mostly tracking allocations using memreport for assets, and xcode’s allocations instrument for pretty much everything else.

However, we’ve found that this approach has some serious blind spots, there are some allocations that for whatever reason, the allocations instrument doesn’t seem to see (despite the debugging session reporting an increase in memory usage), and memreport only returns information about types that have implemented GetResourceSizeEx. This leaves a large amount of our program invisible.

Are there other tools that we could investigate that would allow us to get a better sense of allocations in systems that aren’t tied to assets (and that don’t generate so much noise that getting usable info is relatively manageable)? Or is there an engine level way to assign memory pools to different systems in our code so that we can control the amount of memory that gets allocated where, and have an easy way to detect when something unexpected has occurred (ie/ we crash because that pool runs out of memory?)

The most detailed memory reporting system we currently have is the malloc profiler system which logs all allocations and outputs a .mprof file. We then have the MemoryProfiler2 tool which can load those logs and let you inspect memory usage. Usually, it’s a combination of this system and the “mem” / “memreport” type tools that let us manage the memory in our own internal games.

You can enable the malloc profiler by setting bUseMallocProfiler to true in your BuildConfiguration.xml. After that, there will be a .mprof file created in the Saved\Profiling directory of your project, which you can then open using MemoryProfiler2.