I'm losing my memory (GC & NSImageView)
I'm losing my memory (GC & NSImageView)
- Subject: I'm losing my memory (GC & NSImageView)
- From: Stuart Rogers <email@hidden>
- Date: Sun, 4 Nov 2007 15:10:53 +0000
I'm working on a simple image compositor application, and I have a
memory usage/leak problem that I really can't pin down (I have garbage
collection enabled). The compositor has an NSImageView panel for
the composited/filtered/scaled-down images, and an NSSlider for
scrubbing back and forth through the frames. The source images are
numbered sequences of TGA files (typically 1280x720 pixels).
Whenever the slider updates, it triggers a redraw.
The problem is that within a very short period of moderate scrubbing
(causing maybe 1000 redraws over a period of about a minute or two)
I can fill up my G5's 5GB of RAM and cause the creation of multiple
swap files.
Here's the redraw code. At most it occurs once per event cycle:
// Fetch the composition; bounds is an NSRect
CIImage *imgResult = [layerManager renderFrame:frameNumber
toSize:bounds];
NSImage *image;
NSCIImageRep *imgRep;
// Crop the image to the required size
CIFilter *crop = [CIFilter filterWithName:@"CICrop"];
CIVector *frameSize = [CIVector vectorWithX:0.0 Y:0.0
Z:bounds.size.width W:bounds.size.height];
[crop setValue:imgResult forKey:@"inputImage"];
[crop setValue:frameSize forKey:@"inputRectangle"];
CIImage *finalImage = [crop valueForKey:@"outputImage"];
// Create an NSImage from the result.
imgRep = [NSCIImageRep imageRepWithCIImage:finalImage];
image = [[NSImage alloc] initWithSize: NSMakeSize(bounds.size.width,
bounds.size.height)];
[image addRepresentation:imgRep];
// Display the result; previewView is an NSImageView
[previewView setImage:(NSImage*)image];
Once this is done, the only thing holding on to the image is
previewView,
the NSImageView that displays the result. When previewView gets a
new image, I would expect the garbage collector to eventually dispose
of the previous image, but there's little evidence this is occurring.
On a
couple of occasions I've seen some memory reclaimed, but not much.
I know GC generally doesn't result in immediate clean up, but this is
getting messy.
ObjectAlloc (within Instruments) reckons I'm using far less memory (of
the order of tens of megabytes). Leaks shows a 'negligible' 500kB.
I'm confused.
I would be grateful to anyone who can shed some light on to what may
be the cause of my problem, and eternally so to anyone who can help
me overcome it.
OT: OMG! ApKiDo won't launch on my machine!
Stuart Rogers / Dual 2.5GHz G5 + 5GB RAM + OS X 10.5
_______________________________________________
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