Re: Memory not freed with CIImage

2008-06-12 Thread Fabian
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 PROTECTED] 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 (Cocoa-dev@lists.apple.com)

 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:
 http://lists.apple.com/mailman/options/cocoa-dev/slasktrattenator%40gmail.com

 This email sent to [EMAIL PROTECTED]

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Memory not freed with CIImage

2008-06-12 Thread Robert Cerny


On 12.6.2008, at 7:48, Stefano Falda 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


Hi,
I find Instruments weird too, but there is a lot of power there. Do  
you know you can simply build your application and choose from menu:  
Run - Start with Performace Tool - Leaks?


HTH
Robert
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Memory not freed with CIImage

2008-06-12 Thread Stefano Falda

WOW it worked!
Thank you very much...

Anyone filed a bug notice of this to Apple?

Thanks to everybody for the suggestions

Stefano

On 12/giu/08, at 11:51, Fabian wrote:


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:


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Memory not freed with CIImage

2008-06-11 Thread Stefano Falda

Hello,
 I've got some code similar to the following, in which I loop in a  
list of image files and  draw their content to another image.


I'm working with X-Code3 under Leopard with Garbage Collection ON, but  
something seems to go wrong, because at the end of all the operations  
the memory is not released (in Activity Monitor there are 400 MB  
still active that disappear if I close my application).


I've tried using NSImage instead of CIImage and everything seems to  
work ok, the memory goes up and then down to where it was before the  
operation, but the process takes 1.52 times more than with CIImage.


This is an extract of the code:

for (id loopItem in images) {
NSString * imageFileName=(NSString*) loopItem;

			destRect=NSMakeRect(currentPos.x, currentPos.y, mosaicSize.width,  
mosaicSize.height);


			CIImage* thisImage2=[CIImage imageWithContentsOfURL:[NSURL  
fileURLWithPath:imageFileName]];

if (thisImage2!=NULL)
{
[thisImage2 drawInRect:destRect fromRect:NSMakeRect(0,0,  
[thisImage2 extent].size.width,[thisImage2 extent].size.height)  
operation:NSCompositeSourceOver 	fraction:1.0];	

}
}

Maybe I'm missing something very stupid, because I'm new to Objective- 
C and Mac Programming.


I thought that, being a newbie, using Garbage Collection I could ease  
my life, but I'm thinking if I need to recode this project with  
standard memory management.


I hope that someone can explain where I'm making something wrong.

Thank you

Stefano
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Memory not freed with CIImage

2008-06-11 Thread Nick Zitzmann


On Jun 11, 2008, at 3:53 PM, Stefano Falda wrote:

I'm working with X-Code3 under Leopard with Garbage Collection ON,  
but something seems to go wrong, because at the end of all the  
operations the memory is not released (in Activity Monitor there are  
400 MB still active that disappear if I close my application).



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/

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Memory not freed with CIImage

2008-06-11 Thread Stefano Falda

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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]