Leak in NSImage drawInRect with ColorSync profile?
Leak in NSImage drawInRect with ColorSync profile?
- Subject: Leak in NSImage drawInRect with ColorSync profile?
- From: glenn andreas <email@hidden>
- Date: Wed, 25 Oct 2006 17:31:18 -0500
So I've got some code that look like:
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:&myRGBData
pixelsWide:myWidth / scale pixelsHigh:myHeight / scale
bitsPerSample:8 samplesPerPixel:3 + myAlpha
hasAlpha:myAlpha isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bytesPerRow:alignwidth(myWidth)*(3 + myAlpha)
bitsPerPixel:8 * (3 + myAlpha)];
NSImage *image = [[NSImage alloc] initWithSize:NSMakeSize(myWidth /
scale, myHeight / scale)];
[image addRepresentation:bitmap];
if ([myPostProcess nonTrivial]) {
[bitmap setProperty:NSImageColorSyncProfileData withValue:
[myPostProcess colorSyncProfile]];
}
[bitmap release];
[image drawInRect:[self bounds] fromRect:NSMakeRect
(0.0,0.0,myWidth / scale, myHeight / scale)
operation:NSCompositeSourceOver fraction:1.0];
[bitmap setProperty:NSImageColorSyncProfileData withValue:NULL];
[image release];
[pool release];
The idea being that, if there is some post-processing color
correction, we use attach a ColorSync profile to the bitmap and then
draw it. Looks great on the screen - slide the "contrast" slider,
and the image's contrast adjusts perfectly (this is designed to work
on 10.3.9 so no CoreImage filters, not to mention that this also
allows me to embed the ColorSync profile when saving the image). The
problem is that it appears that if there is a profile attached to the
bitmap, drawInRect ends up allocating memory that never gets freed.
ObjectAlloc shows chunks of 3/4 Meg are allocated:
Event: (#647698) AllocationEvent
Time Index: 183507447.401161
Category: GeneralBlock-782336
Pointer: 0x17e3c000 Size: 782336
Thread: 0xd03 Extra Data: 0x0
Backtrace:
img_data_lock
CGSImageDataLockWithReference
0x9471d538
0x9471bcd0
CGContextDelegateDrawImage
CGContextDrawImage
-[NSBitmapImageRep
_drawFromRect:toRect:operation:alpha:compositing:flipped:ignoreContext:]
-[NSImage drawInRect:fromRect:operation:fraction:]
-[QuiRenderView refreshWithRGBData:]
I've added the autorelease pool to attempt to make sure that
everything (the image and bitmap) are freed, but no help - same with
reseting the bitmap's color sync profile (and from looking at
ObjectAlloc, it definitely appears that both the image and bitmap are
released - there's no leaks of them). There are also smaller
allocations for ColorWorlds (also not freed):
Event: (#474509) AllocationEvent
Time Index: 183507439.623727
Category: GeneralBlock-24576
Pointer: 0x17855000 Size: 24576
Thread: 0xd03 Extra Data: 0x0
Backtrace:
CMMMemMgr::New(unsigned long, char const*)
CMMBase::NewInternal(unsigned long, CMMMemMgr&, char const*)
CMMTable::CMMTable[unified](unsigned long, CMMMemMgr&, CGFunction*)
CMMParaCurveTag::MakeLutTable(CMMFloatLutInfo*, CMMMemMgr&,
CMMLutRangeMapping)
CMMRGBCurves::MakeLutTable(CMMFloatLutInfo*, CMMMemMgr&, unsigned long)
ConversionManager::AddMatrixConv(CMMXYZTag* (&) [3], CMMRGBCurves&)
ConversionManager::MakeConversionSequence(CMMProfileInfoContainer*,
CMMColorConversionInfo*)
ConversionManager::MakeColorMatchSequence(CMMProfileInfoContainer*,
CMMColorConversionInfo*)
CMMMakeColorMatchConversion(CMMMemMgr&, CMMProfileInfoContainer*,
CMMColorWorldData*, unsigned long)
DoNConcatInit
NCWConcatColorWorld
0x946c88a8
0x946d05a0
0x946c8270
0x946c80f8
0x946c8088
CGColorTransformConvertNeedsCMS
img_data_lock
CGSImageDataLockWithReference
0x9471d538
0x9471bcd0
CGContextDelegateDrawImage
CGContextDrawImage
-[NSBitmapImageRep
_drawFromRect:toRect:operation:alpha:compositing:flipped:ignoreContext:]
-[NSImage drawInRect:fromRect:operation:fraction:]
-[QuiRenderView refreshWithRGBData:]
So any idea how to release this memory? Or is this just a plain old
bug (and any suggested work arounds)?
Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build,
mutate, evolve, animate
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden