Does every thread need its own autorelease pool?

后端 未结 3 581
南旧
南旧 2020-12-17 04:46

Does every thread have to have its own pool? I am writing an iPhone app which uses threads. If I do not put a pool on a thread it complains abut leaking.

What I wan

3条回答
  •  爱一瞬间的悲伤
    2020-12-17 05:28

    If you don't need a runloop associated with your thread, you'll need to create an autorelease pool manually. I would suggest that for transferring ownership of an object to another thread, you make it explicit rather than trying to rely on autorelease; have some sort of "take ownership" method called on a longer-lived thread that retains it.

提交回复
热议问题