0

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)

4

1 回答 1

1

3retainCount是红鲱鱼;无用的分心。 http://www.whentouseretaincount.com等等。

由于您有一个反复泄漏的场景,Heapshot 分析应该有助于准确确定内存滞留的原因。

但是,您可能不需要走那么远。如果您的应用程序只有一个 UIWebView,那么您应该能够简单地将分配工具配置为仅跟踪活动对象并跟踪保留/释放事件。这样,将内存中的对象列表过滤到 UIWebView 并单击到与对象关联的保留/释放事件列表。将在那里找到额外的保留。

然而,这可能是一种症状,而不是原因。原因可能是缓存出错,或者可能是其他一些未正确释放的对象挂在 Web 视图上。

于 2013-04-05T15:18:08.567 回答