iOS:ARC,没有释放内存 [英] iOS : ARC, not freeing memory

查看:131
本文介绍了iOS:ARC,没有释放内存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS应用程序存在一个奇怪的问题。
一段时间后我的应用程序在内存中变低,因此内存警告,一切似乎都很好,但是当我检查内存使用情况时,我注意到所有对viewDidUnload的调用都没有释放大量内存,所以在很少点击我的应用程序,它再次在内存警告,一切似乎再次正常,但没有很多内存已被释放,所以它再次在内存警告更快,然后它崩溃(在第三个内存警告后大多数的时间)。这个崩溃是随机的:应用程序冻结,应用程序离开,我的调试器说app暂停,但没有糟糕的访问或sigbort,没有僵尸。
我的猜测是内存警告无法释放足够的内存。

I've kind of a weird issue with my iOS app. after a while my app goes low in memory so memory warning, everything seems to be fine, but when I check the memory usage I noticed that all the calls to viewDidUnload didn't free up lot of memory, so after a few click in my app, it goes again in memory warning, everything seems to be fine again, but not a lot a memory have been released, so it goes again in memory warning faster, and then it crash (after the third memory warning most of the time). this crash is random : app freeze, app leaves, my debugger says app paused, but no bad access or sigbort, no zombies. my guess is that memory warning can't free up enough memory has it should.

(我检查了所有viewDidUnload并将每个在viewDidLoad中分配的对象设为nil)

(I checked all my viewDidUnload and make nil every objects that are allocated in viewDidLoad)

任何帮助都将非常有用!

Any help will be usefull !

非常感谢。

推荐答案

所以我管理处理我的问题。

So I managed to work with my issue.

我在所有控制器中写了 - (void)dealloc方法,并检查我是否应该输入它。 (在流行音乐控制器,解散等..)

I wrote "-(void) dealloc" methode in all my controllers and check if I enter in it as I should. (on pop controller, dissmiss etc..)

每次没有,我会在控制器中一步一步地看看是什么让我的控制器保留了自己的控制权。

Every time it didn't, I do step by step in the controller to see what was retaining my controller from beeing dealloc.

大多数情况下,某些财产不属于不安全未被分配的
代表(并且不应该分配给in unsafe_unretained)
(来自非ARC项目的遗产......)

most of the time it was some property that was not in "unsafe_unretained" delegate that was in "ASSIGN" (and should not be in assign but in unsafe_unretained) (heritage from non-ARC project...)

我还有一些奇怪的控制器与XIB即使是空的也没有被释放。
我用复制/粘贴一步一步地重建新的,最后用完全相同的代码,新的控制器被释放,之间没有明显的区别! gnneee

I also had some strange controller with XIB that was not deallocated even if empty. I rebuild new one step by step with copy/paste and finaly with exactly the same code, the new controller was released, with no visible difference between then !!! gnneee

至少我知道现在如何调试这类问题......

at least I know how to debug that kind issues now...

这篇关于iOS:ARC,没有释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆