When memory becomes low, the System would send that UIApplicationDidReceiveMemoryWarningNotification notification. But I don't get it... that isn't a Method I must implement in my App Delegate, right? How do I get this notification?
You would implement the "applicationDidReceiveMemoryWarning:(UI Application *)application" in your app delegate.
This is a warning notification telling you that you are about to exceed your memory limitation, at which point, the OS will kill your application process - in the applicationDidReceiveMemoryWarning you have the chance to free up and release some memory to prevent the OS from killing your app.
@interface MyApp: NSObject <UIApplicationDelegate>
{
}
@end
@implementation
-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
[[TextureMgr sharedTextureMgr] removeAllTextures];
}
@end
That's the standard 'Cocos2D-iphone' implementation of the function.
Your app delegate can implement the -applicationDidReceiveMemoryWarning:
method. Other objects can register as observers for UIApplicationDidReceiveMemoryWarningNotification
. See the section in the docs on "Managing your memory usage", at http://developer.apple.com/iphone/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MemoryAlloc.html#//apple_ref/doc/uid/20001881-SW1