I'm in the final development phase for an app which uses the JASidePanels control to display a menu on the left of the application (the app has 5 main sections).
I'm now heavily relying on XCode's Instruments to locate CPU and memory bottlenecks, and I've noticed switching the center view controller does not seem to free any memory. Because of that, as the app is used, the memory grows and triggering a memory warning does not seem to help much.
I use the following method to switch the center panel when an item from the left panel menu is tapped on :
- (void)updateCenterViewControllerWithIdentifier:(NSString *)storyboardIdentifier;
{
@try {
self.centerPanel = [self.storyboard instantiateViewControllerWithIdentifier:storyboardIdentifier];
} @catch (NSException *exception) {
DDLogError(@"%@", exception);
}
}
If someone is familiar with the control and knows what I'm possibly doing wrong, it would be absolutely great to have some advice. Thanks in advance
I think that the problem is with exception handling. Try-catch is causing memory leaks in ARC. Details you can find e.g here: https://stackoverflow.com/a/27142288/1073388
The other thing is that you shouldn't use exception handling to handle nib loading problems. The only problem that could cause exception is a wrong nib name, but this could be checked and repaired during the development. Exceptions should be used only in situation that exceptional behaviour cannot be predicted and an application should be terminated after abnormal execution of code block.