监听对象释放。优化log输出#4
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
通过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,导致奔溃(在一个退出的线程,当然这个时候线程没有释放,执行方法奔溃)