objective c - Weird memory leak with Blocks and copying in certain way in ARC -


the following simple code, under arc, in latest xcode (4.6.2) shows leaks when profiled leaks instrument, in ios simulator, in release build configuration -os optimization:

- (bool)application:(uiapplication *)application   didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     (int = 0; < 10; i++)     {         void (^block)() = ^         {             nslog(@"%d", i);         };          id x = block;         [x copy];     }      return yes; } 

it shows 10 leaked blocks. (it not show leaks optimization turned off; turning off optimization not realistic our app.) strange thing is, looking @ memory management history each of leaked blocks, fine -- each has malloc copy , release; release somehow not deallocate it?

is compiler bug (it using default apple llvm compiler)?

this seems either bug in compiler or leaks instrument, not sure which. should file bug apple.

the same leak happens when shortening code this:

int = 0; void (^block)() = ^{     int y = i; };  id x = block; 

the leak appears if block references local variable parent scope.

do see happening in real production code or in example?


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -