2

It seems like ARC is calling [[obj retain] autorelease], when assigning like

Foo* foo = [Foo getInstance]

Thats why I have to add a pool there, if it's happening on a BG thread.

@autoreleasepool
{
  Foo* foo = [Foo getInstance]
}

Does ARC do retain-autorelease combo for any object ref in the method, that is not explicitly created/copied (init/copy)?

fspirit
  • 2,537
  • 2
  • 19
  • 27
  • ARC does not use a single technology - don't try to second guess it. Objects are either "live" or not. You need the autorelease pool since the frameworks use it - they are not ARC per se, and so they have to vend objects that are autoreleased. – David H Aug 23 '12 at 15:49
  • 2
    Rather than worrying about the internals of ARC, it's probably best to code defensively and place an autorelease pool within code performed in a manually created background thread. Note that you don't need this for blocks dispatched to a background queue via GCD, since [that handles all this for you](http://stackoverflow.com/questions/4141123/do-you-need-to-create-an-nsautoreleasepool-within-a-block-in-gcd). – Brad Larson Aug 23 '12 at 17:58

0 Answers0