Iphone error due to low memory but works fine in simulator

Dear, I have a navigation app with about 60 UIControllerViews that is divided into 4 sections.

I've worked with the following: 1. Build and parse: bulid successfully, no complaints. 2. Appliance distribution and leakage: no leakage.

However, the app crashed on iPhone or iPad, but works fine in the simulator. There are no crash reports, but I can see LowMemory.log in the crashreporter folder.

I have updated my iphone and ipad to 4.2

Does anyone have any idea what might be wrong? I've been reading and troubleshooting for a week.

Do I need to remove / release UIControllerViews? The app is simply uninstalled by navigating between views.

Thanks for any help.

My app has a root view called contentViewController and users can navigate to 4 polls from here.

This is the code I am using to return to the root view.

- (void)goHome {
UIAlertView *alert = [[UIAlertView alloc]
                      initWithTitle: @"Warning"
                      message: @"Proceed?"
                      delegate: self
                      cancelButtonTitle:@"Yes"
                      otherButtonTitles:@"No",nil];
[alert show];
[alert release];

      

}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
[[self navigationController] setNavigationBarHidden:NO animated:YES];
if (buttonIndex == 0) {
    NSArray * subviews = [self.view subviews];
    [subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
    self.view = nil;
    if (self.contentViewController == nil)
    {
        ContentViewController *aViewController = [[ContentViewController alloc]
                                                  initWithNibName:@"ContentViewController" bundle:[NSBundle mainBundle]];
        self.contentViewController = aViewController;
        [aViewController release];
    }
    [self.navigationController pushViewController:self.contentViewController animated:YES]; 
}
else {
}

      

}

0


source to share


4 answers


The simulator won't give you any useful information about memory warnings - your application running there effectively has access to all the system memory ready to give it. The device is designed to test memory usage, and if you get warnings and crashes, you need to do some tools to figure out where you can free some of that memory.



+3


source


Have a look at the xcode console. If you get multiple low memory warnings, then you need to allocate and deactivate your views on the fly because they are taking up too much memory on the device (the simulator is not so memory constrained).



But it could be about a million other things causing you to crash. Make sure you are doing a debug build (breakpoints) so the debugger will start working and hopefully you can see where on the stack the failure occurred.

+1


source


You already have good suggestions. However, I would suggest spending a lot of time analyzing the Xcode Debugging Tools documentation. This way, you have a basic understanding of what they are capable of and how to use them. Follow along by reading some information about iOS memory management, auto-release pools, and more.

For your application, you need to understand that there is no swap space on iOS devices. Thus, you are forced to manage memory to the point that you shouldn't on other platforms. This usually means that you don't want to store a lot of data in memory if you can avoid it.

In the case of the current iPad, there might be about 110MB of RAM available for the app. The specific numbers probably depend on the iOS version. Either way, you need to get an idea of ​​how big the data structures (in memory) are for different views. There can be 60 different sorts of things to consider depending on your memory usage, if you don't handle it correctly, you will most likely finish very quickly. This is not like Java programming or any other garbage collector.

Finally; while this sounds like a memory management problem, it could always be something else. If you still have problems, you will need to submit a code. Now this is really guessing work on our part. Just remember that you have no virtual machine and no garbage.

0


source


You are using memory, always remember, if you allocate memory that you should release it, in some cases you can use auto-advertisements, so remember to free it after the void dealloc method until the end.

0


source







All Articles