I've got a simple app which is just loading a view controller which contains a UIWebView. While running it I noticed that the amount of memory reported by XCode increases from 2 MB before the vc is allocated up to 12.5Mb after its been created. But then after the vc is deleted the amount of memory doesn't go down, in fact it rises even further to 13Mb. However XCode's leaks analyser doesn't report any problems.
The view controller is created and destroyed here from within the app's main (and only other) view controller:
- (void) viewDidAppear:(BOOL)animated
{
static BOOL presented = NO;
if (!presented)
{
PresentationViewController *vc = [[PresentationViewController alloc] initWithPresentationId:@"index.html"];
__weak typeof(vc) weakVc = vc;
[vc setExitBlock:^{
[[weakVc presentingViewController] dismissViewControllerAnimated:YES completion:nil];
}];
[self presentViewController:vc animated:YES completion:nil];
presented = YES;
}
}
And the view controller's dealloc is called so it is being destroyed, and yes the web view delegate is being nilled.
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
[self.webView stopLoading];
self.webView.delegate = nil;
}
Why isn't the memory consumption going down when the view controller is deleted?