多线程中的 autoreleasepool

[myObj performSelectorInBackground:@selector(doSomething) withObject:nil];

这种方式开启一个子线程执行任务的话,是否需要在 doSomething 里加入

@autoreleasepool {}
阅读 4.7k
1 个回答

three occasions when you might use your own autorelease pool blocks:
第3条:If you spawn a secondary thread.

If your application or thread is long-lived and potentially generates a lot of autoreleased objects, you should use autorelease pool blocks.If your detached thread does not make Cocoa calls, you do not need to use an autorelease pool block.

Advanced Memory Management Programming Guide.pdf

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题