Hi Seth.

You might want to try putting an autorelease pool around your method. See the 
"Tip" in this document:

https://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/CoreImaging/ci_tasks/ci_tasks.html%23//apple_ref/doc/uid/TP30001185-CH203-TPXREF101

I've used this tip before to fix what appeared to be a memory leak in my app.

-Jeff


On Jan 16, 2011, at 3:03 AM, Seth Willits wrote:

> I have a CALayer subclass and I'm drawing into it using Core Image. I'm 
> taking a CGImage, blurring, and adding a darkened radial gradient on top of 
> it. Pretty simple. Now the weird thing is, using Core Image for drawing this 
> image (instead of just drawing with no effects using CGContextDrawImage) 
> increases my app's memory usage by 30 MB. That almost doubles the entire 
> usage of my app. 
> 
> It's not like I'm leaking any memory here, so why the large permanent 
> increase? I'd like to avoid it if I can because I'm getting criticized for 
> "using too much memory" despite it not being my fault. :-p
> 
> 
> 
>       - (void)drawInContext:(CGContextRef)theContext
>       {
>               CIImage * image = [CIImage 
> imageWithCGImage:(CGImageRef)self.backgroundImage];
>               CGRect imageRect = [image extent];
>               
>               CIFilter * blur = [CIFilter filterWithName:@"CIGaussianBlur"];
>               [blur setValue:image forKey:@"inputImage"];
>               [blur setValue:[NSNumber numberWithInt:2] 
> forKey:@"inputRadius"];
>               
>               CIFilter * gradient = [CIFilter 
> filterWithName:@"CIRadialGradient"];
>               CGPoint center = CGPointMake(CGRectGetMidX(imageRect), 
> CGRectGetMidY(imageRect));
>               [gradient setValue:[CIVector vectorWithX:center.x Y:center.y]   
>                         forKey:@"inputCenter"];
>               [gradient setValue:[NSNumber numberWithInt:0.0]                 
>                                         forKey:@"inputRadius0"];
>               [gradient setValue:[NSNumber numberWithInt:600.0]               
>                                         forKey:@"inputRadius1"];
>               [gradient setValue:[CIColor colorWithRed:0.0 green:0.0 blue:0.0 
> alpha:0.3]      forKey:@"inputColor0"];
>               [gradient setValue:[CIColor colorWithRed:0.0 green:0.0 blue:0.0 
> alpha:0.6]      forKey:@"inputColor1"];
>               
>               CIContext * context = [CIContext 
> contextWithCGContext:theContext options:NULL];
>               CGRect extent = [image extent];
>               [context drawImage:[blur valueForKey:@"outputImage"]     
> inRect:self.bounds fromRect:extent];
>               [context drawImage:[gradient valueForKey:@"outputImage"] 
> inRect:self.bounds fromRect:extent];
>       }
> 
> 
> 
> --
> Seth Willits

_______________________________________________

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 arch...@mail-archive.com

Reply via email to