Re: bitmapData leak
Re: bitmapData leak
- Subject: Re: bitmapData leak
- From: Jonathan Taylor <email@hidden>
- Date: Mon, 11 Apr 2011 14:15:38 +0100
OK, after much wailing and gnashing of teeth I have worked out my mistake. Where I wrote the following:
> NSImage *frameImage = [[NSImage alloc] initWithContentsOfFile:NSStringForFrameNumber(i)];
>
> // Temp code to debug serious memory leak
> NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
>
> NSBitmapImageRep *bitmapRep = RawBitmapFromImage(frameImage);
> /* If I comment out the following line then there are no major leaks.
> With this line in place, bitmapData is leaked, in that ObjectAlloc
> shows a whole load of allocations from within the call to bitmapData
> that build up until all memory is full. */
> unsigned char * bitMapDataPtr = [bitmapRep bitmapData];
>
> [pool drain];
> [frameImage release]; // I have tried swapping these two calls around, to no effect (unsurprisingly)...
what was happening was that *** frameImage *** was not being autoreleased until the full loop was over (obviously). Although the actual pixel data allocation was occuring within the scope of my autorelease pool, that buffer was not being freed up until the image object itself was autoreleased. I guess that makes sense, though I'm finding this sort of autorelease consideration rather hard to get to grips with...
Jonny
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden