Triggering Simulator Memory Warnings with AppleScript

Since we are testing memory footprint, it would be great if we could trigger memory warnings in iOS Simulator from our scripts. When an iOS application receives a memory warning, Apple says any cached data that can be easily re-created should be discarded. This is often a source of latent bugs because we’re either not disposing of this cached information like we should, or we dispose of cached information that is still in use.

Memory warnings are triggered manually within iOS Simulator by choosing Simulate Memory Warning from the Hardware menu, like we see in Figure 43, Simulating a memory warning. Thanks to some AppleScript magic and the UIAHost object, we can trigger these at any point ...

Get Test iOS Apps with UI Automation now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.