Re: CIImage drawAtPoint: ...... retains image??
Re: CIImage drawAtPoint: ...... retains image??
- Subject: Re: CIImage drawAtPoint: ...... retains image??
- From: Rob Keniger <email@hidden>
- Date: Sat, 15 Dec 2007 23:07:43 +1100
On 15/12/2007, at 10:44 PM, Andreas Monitzer wrote:
I'm seeing the same issue in my program. As soon as I try to render
the CIImage somehow (to my view or offscreen), the whole image
leaks. Since I'm drawing fullscreen images regularly, my application
leaks 60MB of RAM per cycle (verified using Instruments). The memory
is never freed in any way, it just builds up.
I haven't found a solution yet, even though I spent a whole day
trying different ways to get the pixels out of the CIImage (all of
them leaking). I'm thinking about scrapping CIImage altogether and
re-implementing all CoreImage filters I'm using using direct OpenGL
calls and some shaders. That's much more work, but at least I can
fix those leaks that way.
I had this exact problem and it seems to occur if you are drawing to a
context that is not on-screen. I was leaking HUGE amounts of memory
until I found a fix.
I used this workaround which renders the CIImage to the context of the
application's main window (you can use any on-screen context) and
grabs a CGImageRef which is then drawn to the current context:
//outputImage is the CIImage you want to draw
CIContext *ciContext = [[[NSApp mainWindow] graphicsContext] CIContext];
//render the CIIimage into a CGImageRef in the on-screen context
CGImageRef cgImage = [ciContext createCGImage:outputImage fromRect:
[outputImage extent]];
// Draw the CGImageRef into the current context
if (cgImage != NULL)
{
CGContextDrawImage ([[NSGraphicsContext currentContext]
graphicsPort], [outputImage extent], cgImage);
CGImageRelease (cgImage);
}
This eliminates the problem for me.
--
Rob Keniger
_______________________________________________
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