Memory leak with blocks and ARC
| Originator: | sven.weidauer | ||
| Number: | rdar://14023009 | Date Originated: | 30-May-2013 04:26 PM |
| Status: | open | Resolved: | |
| Product: | iOS SDK | Product Version: | Xcode 4.6.2, LLVM Compiler 4.2 |
| Classification: | Reproducible: | Always |
Summary:
Assigning a local block that accesses a local variable from the parent scope to a local variable typed id leads to instruments reporting a memory leak of type __NSMallocBlock__.
Steps to Reproduce:
Compile this application delegate method in release mode in Xcode 4.6.2 with the LLVM 4.2 compiler using ARC and run in the leaks instrument:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
int i = 0;
void (^block)() = ^{
int y = i;
};
id x = block;
return YES;
}
Expected Results:
No leaks.
Actual Results:
It leaks a __NSMallocBlock__ instance which gets allocated in _Block_copy_internal.
Notes:
I am not sure if this is a problem in the compiler or in instruments.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!