I have a distilled use case of enqueuing blocks to a GCD queue (see below
for the snippet) implemented in both Objective-C and Objective-C++, where
the Debug build of the Objective-C++ version shows a steadily growing
memory footprint.
The Objective-C version shows a similar memory footprint for both Debug and
Release builds (holding steady after the initial app load). For a Release
build, the Objective-C++ version shows a similar footprint to the
Objective-C version.
The Objective-C++ Debug build, however, shows the memory footprint steadily
growing. Profiling in Instruments suggests that the enqueued blocks are not
being released after executing.
This seems to be a bug, but is there a reason this would happen in the
Debug build with Objective-C++ but not Objective-C? Did I do something
wrong? Is there a way to work around it? I'm less concerned than I would be
if it were also happening in a Release build, but it tends to make lengthy
Debug testing difficult.
@interface Enqueue ()
@property (strong) dispatch_queue_t queueOne;
@property (copy) void (^blockOne)(void);
@end
@implementation Enqueue
- (void)enqueueNext {
self.queueOne = dispatch_queue_create("memoryGrowth",
DISPATCH_QUEUE_SERIAL);
__weak Enqueue* weakSelf = self;
self.blockOne = ^{
Enqueue* strongSelf = weakSelf;
if (strongSelf) {
NSLog(@"Executing");
dispatch_async(strongSelf.queueOne, strongSelf.blockOne);
}
};
dispatch_async(self.queueOne, self.blockOne);
}
@end
Thanks,
Jon
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com
This email sent to [email protected]