Try the search, it's linked to some great forums

Saturday, June 25, 2011

Posting an alert message for low memory warnings

The following code can be used to create an alert message if the application receives a system memory warning.  This method is included in the AppDelegate .m file.

- (void)didReceiveMemoryWarning {
    // Displays an alert message if there is a memory warning
    [super didReceiveMemoryWarning];

//    NSError *error;
//    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);            //error log message
    UIAlertView *memoryAlert = [[UIAlertView alloc] initWithTitle:@"Low Memory Warning"
            message:@"Close some programs!"
            delegate:nil   
            cancelButtonTitle:@"Cancel"
            otherButtonTitles:nil];
    [memoryAlert show];
    [memoryAlert release];   
   
    // Release any cached data, images, etc that aren't in use.
}

The alert message could also be used to log an error code or message.