Sebastian
Sebastian

Reputation: 972

dealloc gets not called for control

I have a sub class of UIWebView and use it in a view controller.

CViewController *controller = [[CViewController alloc] init];
self.webView = controller;
[controller release];

Now in my view controller dealloc gets called and I call [_webView release] but the dealloc in my UIWebView subclass gets never called and the memory usage raise on every time I put one view controller on the stack and never gets released after pop from the stack. Also I can see all my windows in the Safari Development Tools, so they are never be released. I check the retainCount (I know its not very useful) but it told me after the assignment to my property the retainCount is 3? (Property is nonatomic, retain)

Upvotes: 0

Views: 225

Answers (1)

bbum
bbum

Reputation: 162712

The retainCount of 3 is a red herring; a useless distraction. http://www.whentouseretaincount.com and all that.

Since you have a repeatedly leak scenario, Heapshot analysis should help pinpoint exactly why the memory is sticking around.

However, you may not need to go that far. If your app only has one UIWebView, then you should simply be able to configure the Allocations instrument to only track live objects and to track retain/release events. With that, filter the list of objects in memory down to the UIWebView and click through to the list of retain/release events associated with the object. The extra retain(s) will be found there.

That, however, may be a symptom and not the cause. The cause could be caching gone wrong or could be some other object that isn't properly being released that is hanging on to the web view.

Upvotes: 1

Related Questions