Weird Clang/LLVM behavior

Hey guys,

I’m looking at a weird thing going in my project. Wanted to know if you guys know about this or if it’s a bug. I’ve some code like this

dispatch_async(dispatch_get_global_queue(Default, 0), ^{

for (int i = 0; i < 100000; i++) { // a big loop

[a.b doSomethingWithI:i];

}
});

The object “a” uses “forwardInvocation:” to get the property “b” and returns it. Now when I run this I see a huge number of NSInvocation objects being created for the forwardInvocation: never freeing the memory they used although the block is done executing.

Also this only happens when I run it in Debug build. Moreover this never happens on the main queue. Seems like a bug to me but I might be wrong. Any ideas on what’s going on?

Thanks
Mohit

[BCC cfe-dev]

This isn't really a Clang question; it's more about the Objective-C runtime. So the right place would be Apple's Developer Forums or bugreport.apple.com.

But my guess is that the NSInvocations are autoreleased, and (from the Concurrency Programming Guide), "Although GCD dispatch queues have their own autorelease pools, they make no guarantees as to when those pools are drained.".

Jordan