I tried to simulate memory warning on iOS Simulator and it turned out that when the app was in the background, the function didn't get called at that moment, but after the app became active again that the applicationDidReceiveMemoryWarning was being called.

When tested with Instrument:Activity Monitor, my app didn't release any memory when in the background while the other apps memory consumption were getting less.

However, if I call applicationDidReceiveMemoryWarning via applicationDidEnterBackground, the memory get released correctly, but I don't want to release memory at this stage though.

1 Answer
1

Unfortunately, what you want to do is discouraged by Apple in the iOS App Programming Guide. An app briefly enters the background, allowing you to free up memory. After that, the app is suspended and cannot receive messages, except applicationWillTerminate. If a low-memory warning fires, the operating system kills suspended apps as needed.