HeapInspector

Before I left Germany in November 2014 for 5 weeks going to Indonesia and Thailand, I released HeapInspector, which is an iOS debug tool that monitors the memory heap in your app. You can discover memory leaks, no longer needed living objects and more issues directly on your device without ever starting Instruments. Any suggestions or proposals are very welcome. Or just start a Pull Request.

The idea for the HeapInspector was in my mind for a long time. Since ARC is alive we have less crashes or memory pressure. But you can still do a lot of things wrong (retain cycles, static pointer). I’ve seen memory design mistakes that caused crashes and strange behavior in apps. Those errors are mainly caused by a growing codebase and accompanying architecture problems. Identifying those issues  is not easy and time consuming. Apple Instruments can help to analyze the iOS app for memory issues. That is fine if you have enough time and a cable for tethered debugging with your Mac. But for real life debugging (on trains or subways) Instruments wouldn’t be the ideal solution. For some projects we added a label that displayed the current memory usage in Megabytes. This helped us to identify increasing memory and pressures while using the app in real world conditions (bad 3G and so on).
But to find the main reason (i.e. retain cycles) why the memory increased I needed to run Instruments again.
I asked myself: Is there a way to measure and snapshot the memory footprint on the device without Instruments. YES. I need to override ARC and swizzle retain, release, alloc, dealloc,…
I started digging into Clang’s ARC documentation. Also mike ash’s articles inspired me and helped me a lot to understand what goes on behind the scenes. (See links below)

Some Inspirations, Credits & Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *