We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
SO 上的这个答案 https://stackoverflow.com/questions/24562043/is-autoreleasepool-still-required-for-modern-ios-8-nsoperation-usage 提到,系统会自动设置好 Autorelease Pool。
这个答案 https://stackoverflow.com/questions/184409/nsautoreleasepool-in-nsoperation-main 提到说需要手动加入 Autorelease Pool,但是答案本身是 08 年的,所引用的苹果官方文档应该也已经更新了(搜不到对应的内容)。
按照我自己的理解,应该是不需要的,因为 NSOperation 所跑的线程也是 Cocoa 创建的线程,Cocoa 创建的线程中应该就已经设置好 Autorelease Pool 了。
按照文档的说法,Operation 里的 Pool 不一定什么时候会进行 drain,所以添加自己的 Pool 会更利于管理。
The text was updated successfully, but these errors were encountered:
关于你提到的:
Cocoa 创建的线程中应该就已经设置好 Autorelease Pool 了。
子线程中的 Autorelease Pool 不会工作,需要手动开启。因为子线程的runloop默认不工作。
Sorry, something went wrong.
Pool 的工作依赖于 runloop 这一点我倒是没想到,如何手动开启 pool 呢?就是自己再添加一个吗?
@ChenYilong 子线程 runloop默认不工作和 autoreleasePool 不会工作这个是哪里的文档?
到底需不要加autoreleasepool?
No branches or pull requests
SO 上的这个答案 https://stackoverflow.com/questions/24562043/is-autoreleasepool-still-required-for-modern-ios-8-nsoperation-usage 提到,系统会自动设置好 Autorelease Pool。
这个答案 https://stackoverflow.com/questions/184409/nsautoreleasepool-in-nsoperation-main 提到说需要手动加入 Autorelease Pool,但是答案本身是 08 年的,所引用的苹果官方文档应该也已经更新了(搜不到对应的内容)。
按照我自己的理解,应该是不需要的,因为 NSOperation 所跑的线程也是 Cocoa 创建的线程,Cocoa 创建的线程中应该就已经设置好 Autorelease Pool 了。
按照文档的说法,Operation 里的 Pool 不一定什么时候会进行 drain,所以添加自己的 Pool 会更利于管理。
The text was updated successfully, but these errors were encountered: