Skip to content

监听对象释放。优化log输出#4

Merged
bestswifter merged 1 commit into
bestswifter:masterfrom
upworldcjw:master
Sep 28, 2016
Merged

监听对象释放。优化log输出#4
bestswifter merged 1 commit into
bestswifter:masterfrom
upworldcjw:master

Conversation

@upworldcjw
Copy link
Copy Markdown

通过log分析,得出以下结论,帮我们深入了解线程长活问题
//总结:test At: xcode8,ios 9.3.4
//1,当用CFRunLoopRun(),然后调用CFRunLoopStop,此方法是后果会输出current thread,thread dealloc,current thread,thread dealloc ...所以不会用内存问题
//2,当用 [runLoop run];,然后调用CFRunLoopStop,此方法会current thread,current thread,... 最后输出[NSThread start]: Thread creation failed with error 35.然后app卡住,然后app crash. 内存不会暴增。但是线程无法销毁
//3,当用 [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]];,然后调用CFRunLoopStop,此方法会。[ViewController performSelector:onThread:withObject:waitUntilDone:modes:]: target thread exited while waiting for the perform' crash。是因为 [runLoop runMode:NSRunLoopCommonModes beforeDate:[NSDate distantFuture]]; 无法阻塞线程,所以线程很快执行完run 方法。然后线程exit,导致奔溃(在一个退出的线程,当然这个时候线程没有释放,执行方法奔溃)

@bestswifter bestswifter merged commit 4adb348 into bestswifter:master Sep 28, 2016
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

Successfully merging this pull request may close these issues.

2 participants