Apple defines lev = 1 and lev = 2 memory warnings as very different (one is “Hmm, there is not much memory around. Be careful,” the other is “I'm going to kill a process, you have 5 ... 4 .. . 3 ... ")
... but how do you know programmatically which one you got?
I have an iPad app that processes images with special tools, and lv = 1 warnings of memory are inevitable - even when processing the image in small parts, it still uses a lot of memory to display the entire graphical interface, etc.
I get lev = 1 ALL TIME, and there literally can't do anything about it.
lev = 2 memory warnings is another matter entirely. If I get lev = 2, it usually means that some background application takes up a lot of memory or something that the user has done has bloated memory - and I need to take emergency measures so that I don't die. There are things that I can do, but they are all bad for the user (for example, delete the entire GUI, wait a couple of seconds, and then restart it).
So ... I need two different code paths inside "didRecieveMemoryWarning": one for lev = 1 warnings and one for lev = 2 warnings.
EDIT: Warning Level Information: iPhone OS Memory Alerts. What do the different levels mean?
NB: Apple often doesn't “document” things. If we, the developers, adhere to only documented information and without errors in the API, then many (most?) Applications that expand the boundaries will not exist until several iOS releases are later. Instead, we work on bugs, and we develop what actually happens where Apple cannot document it.
EDIT2: ... looking at the associated header file, it looks like it got the main private function that Apple uses to determine the current level: "OSMemoryNotificationLevel OSMemoryNotificationCurrentLevel (void)" - but I think we could not get this past Apple Submission :(?