Is it necessary to create an autorelease pool under ARC in GCD?

前端 未结 2 1825
孤独总比滥情好
孤独总比滥情好 2020-12-16 05:50

I have a run loop method for a CAEAGLLayer which uses GCD for serializing access to shared ivars.

My drawing code currently is constructed like this:



        
2条回答
  •  囚心锁ツ
    2020-12-16 06:10

    From the Apple docs:

    If your block creates more than a few Objective-C objects, you might want to enclose parts of your block’s code in an @autorelease block to handle the memory management for those objects. Although GCD dispatch queues have their own autorelease pools, they make no guarantees as to when those pools are drained. If your application is memory constrained, creating your own autorelease pool allows you to free up the memory for autoreleased objects at more regular intervals.

提交回复
热议问题