How to check if iOS app works well in memory alerts?

Recently, I noticed that sometimes our application crashes immediately after receiving a memory warning. It is very difficult to reproduce this problem on the device, and even in the simulator I get this crash, perhaps in one of ten attempts to "Simulate a memory warning."

What is a good strategy for debugging memory alert handlers, given that problems often arise from too late callbacks, resources accidentally used after being destroyed in the alert handler, etc.

+5
source share
1 answer

Here's an approach that helped me find some serious bugs in my memory alert handlers.

First, I went to the OS X keyboard settings and assigned a shortcut to Simulate a memory warning :

enter image description here

Then, when I started the application in the simulator, I pressed these buttons , so that the Simulator generates dozens of memory alerts per second . By doing this, I would bypass the application. Of course, this rarely happens in the real world, but this stress test helped identify some synchronization, callback, and state issues that I would not have found otherwise.

+5
source

All Articles