I’m developing an app for iOS and I’m running into issues with low memory warnings.
My app is loading a large view with lots of subviews upon tapping a button. The memory usage grows and that’s pretty understandable (from 30 Mb to 80Mb). However when user selects another menu item – this view is released, but! the amount of memory used by the app doesn’t reduce any. I use the following code to release the view:
storeView.hidden = YES;
NSLog(@"%d", [storeView retainCount]);
[storeView removeFromSuperview];
storeView = nil;
NSLog in the second line prints: 1, so after the release it should be deallocated. My implementation of -(void) dealloc; does get called (and I call [super dealloc]; on the last line of it). Yet after that I’m still have low memory warnings.
Instruments found only a couple of leaked NSStrings which couldn’t possible cause memory warnings.
Could you please give any advice?
A release call lowers the retain count, if the retain count is 0 it MIGHT be cleared but it doesn’t have to be. When the retain count is zero and you try to access a variable, it might still work, it might not work. You can’t count on it either way.