Tuesday, 27 August 2013

didreceivememorywarnings message sent to deallocated instance

didreceivememorywarnings message sent to deallocated instance

In my app if I have a view that has been deallocated (via modal dismiss or
navigation stack pop) and I get a memory warning after that, my app
crashes.
I've tested by putting a modal create/dismiss very early on in my app that
looks like this:
WWebViewController *webViewController = [[WWebViewController alloc]
initWithPath:@"http://www.google.com"];
[webViewController setIsModal:YES];
WMainNavController *navController = [[WMainNavController alloc]
initWithRootViewController:webViewController];
[self presentViewController:navController animated:YES
completion:nil];
The web view is pretty simple:
- (void)viewDidLoad
{
[super viewDidLoad];
[self setNavigationDefaultsWithTitle:@"Loading..." withBackButton:YES
withSearchButton:YES deepLinked:false];
webView = [[UIWebView alloc] initWithFrame:[self.view bounds]];
webView.delegate = self;
[self.view addSubview:webView];
[webView scalesPageToFit];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL
URLWithString:self.path]]];
[self showNoConnectionImageIfNecessary:NO];
// Do any additional setup after loading the view.
}
...
- (void)dealloc {
[webView loadHTMLString:@"" baseURL:nil];
[webView stopLoading];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[webView setDelegate:nil];
webView = nil;
}
However, simply presenting and then dismissing this view followed by
simulating a memory warning gives this:
*** -[WMainNavController retain]: message sent to deallocated instance
0xba953c0
I've tried this by calling WWebViewController directly without
WMainNavController, tried by using a regular navigation controller, tried
simply pushing something to a nav stack. It always crashes if I have
popped or dismissed a view anywhere in the app.
Am I doing something fundamentally wrong? If I progress through the app
without dismissing/popping it handles memory warnings fine, and there is
only one screen before this which presents this screen as a modal and is
the root view of the program.
I'll provide any extra information needed, has anybody seen something like
this?
Edit -- This is an ARC implementation.

No comments:

Post a Comment