Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HWWeakTimer未释放 #5

Open
ChenTF opened this issue Aug 17, 2016 · 3 comments
Open

HWWeakTimer未释放 #5

ChenTF opened this issue Aug 17, 2016 · 3 comments

Comments

@ChenTF
Copy link

ChenTF commented Aug 17, 2016

您好,我运行Demo中的程序, 发现HWWeakTimer类的dealloc方法不会走,是不是说明有个HWWeakTimer对象不能被释放呢?

@ChenTF
Copy link
Author

ChenTF commented Aug 17, 2016

如果将DetailViewController的dealloc中的[time invalidate]注释掉, HWWeakTimer的Fire方法会一直走, 并且HWWeakTimer对象的target现在持有的detailVC的指针(野指针)这很危险!!

@xshfsky
Copy link

xshfsky commented Sep 14, 2016

经过测试发现,通过实例化对象传NSTimer的target和self传target这两种方式可能有所不同。

@lovelyCiTY
Copy link

因为系统对target的引用方式是autorelease的,这个必须调用invalidate方法重置一下target,系统才会去释放那块内存,让引用停止,这就是重置target和将self变成弱引用都会造成循环引用的原因,可以用symbolic breakpoints进行查看。所以感觉重置代理的方式解决不了问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants