• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Memory not freed with CIImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory not freed with CIImage


  • Subject: Re: Memory not freed with CIImage
  • From: Fabian <email@hidden>
  • Date: Thu, 12 Jun 2008 11:51:59 +0200

>From the archives, originally posted by Rob Keniger:

I had problems with this too, and I use a workaround I found somewhere
where you render to a CGImageRef in the context of the current window.
Here's a dump of the code:

//theImage is an existing NSImage
CIImage *outputImage = [CIImage imageWithData:[theImage TIFFRepresentation]];

//to draw the image processed by Core Image, we need to draw into an
on-screen graphics context
//this works around a bug in CIImage where drawing in off-screen
graphics contexts causes a huge memory leak

//get the current window's graphics context so that we have an on-screen context
//usually we would use any view's window but generically you can just
ask for the main window
CIContext *ciContext = [[[NSApp mainWindow] graphicsContext] CIContext];
if(ciContext == nil)
{
       NSLog(@"The CIContext of the main window could not be accessed.
Bailing out of the image creation process.");
       return;
}

CGAffineTransform transform;
transform = CGAffineTransformMakeTranslation(0.0,[outputImage
extent].size.height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
outputImage = [outputImage imageByApplyingTransform:transform];

//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);
}

HTH

On Thu, Jun 12, 2008 at 7:48 AM, Stefano Falda <email@hidden> wrote:
> On 12/giu/08, at 00:34, Nick Zitzmann wrote:
>
>> It's normal for physical memory sizes to go up, and not come down until
>> either the program is quit or the physical memory is needed elsewhere.
>> Activity Monitor is not a memory leak detector. If you want to know where
>> the memory is going, then use Instruments instead.
>>
>> Nick Zitzmann
>> <http://www.chronosnet.com/>
>>
>
>
> I've tried, but I must admit that Instruments confused me... :-(
>
> Anyway, why the memory is marked as Active under Activity Monitor, and the
> iMac performance become sluggish, while this doesn't happen when using
> NSImage?
>
> Thank you
>
> Stefano
>
> _______________________________________________
>
> 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
>
_______________________________________________

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

  • Follow-Ups:
    • Re: Memory not freed with CIImage
      • From: Stefano Falda <email@hidden>
References: 
 >Memory not freed with CIImage (From: Stefano Falda <email@hidden>)
 >Re: Memory not freed with CIImage (From: Nick Zitzmann <email@hidden>)
 >Re: Memory not freed with CIImage (From: Stefano Falda <email@hidden>)

  • Prev by Date: Re: NSTextView and changing the selected text's color
  • Next by Date: Re: Memory not freed with CIImage
  • Previous by thread: Re: Memory not freed with CIImage
  • Next by thread: Re: Memory not freed with CIImage
  • Index(es):
    • Date
    • Thread