From e4d580bbc10288e463686c599fc567aa143a1d96 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Tue, 11 Aug 2009 14:24:00 -0400 Subject: [PATCH] Plug some memory leaks Some leaks due to autorelease pools and threads, some missed CFReleases etc... --- iPhoto2Ansel/AnselExportController.m | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/iPhoto2Ansel/AnselExportController.m b/iPhoto2Ansel/AnselExportController.m index 4c8a118c8..ec5317fe4 100644 --- a/iPhoto2Ansel/AnselExportController.m +++ b/iPhoto2Ansel/AnselExportController.m @@ -493,13 +493,15 @@ NSString * const TURAnselServerPasswordKey = @"password"; toTarget: self withObject: nil]; [p release]; - [pool release]; + [pool drain]; } // Runs in a new thread. - (void)connect { + NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init]; [anselController connect]; + [threadPool drain]; } // Update our progress controller. Always update on the main thread. @@ -529,6 +531,7 @@ NSString * const TURAnselServerPasswordKey = @"password"; // Runs the actual export (This is run in it's own thread) - (void) runExport { + NSAutoreleasePool *threadPool = [[NSAutoreleasePool alloc] init]; // Init the progress bar and image counts. int count = [mExportMgr imageCount]; currentImageCount = 0; @@ -636,7 +639,7 @@ NSString * const TURAnselServerPasswordKey = @"password"; float finalW = ceilf(yscale * [im extent].size.width); float finalH = ceilf(yscale * [im extent].size.height); - // Do an affine clamp (This essentially make the image extent + // Do an affine clamp (This essentially makes the image extent // infinite but removes problems with certain image sizes causing // edge artifacts. CIFilter *clamp = [CIFilter filterWithName:@"CIAffineClamp"]; @@ -682,11 +685,13 @@ NSString * const TURAnselServerPasswordKey = @"password"; CGImageDestinationSetProperties(destination, (CFDictionaryRef)destProps); // Get the data out of quartz (image data is in the NSData *newData object now. - CGImageDestinationAddImageFromSource(destination, source, 0, (CFDictionaryRef)metadata); - CGImageDestinationFinalize(destination); + CGImageDestinationAddImageFromSource(destination, source, 0, (CFDictionaryRef)metadata); + CGImageDestinationFinalize(destination); + CFRelease(source); [self postProgressStatus: [NSString stringWithFormat: @"Encoding image %d out of %d", (i+1), count]]; NSString *base64ImageData = [NSString base64StringFromData: newData length: [newData length]]; + CFRelease(destination); [newData release]; [theImageData release]; @@ -720,9 +725,10 @@ NSString * const TURAnselServerPasswordKey = @"password"; [keys release]; [values release]; [imageDataDict release]; + [metadata release]; [params release]; [iptcDict release]; - [pool release]; + [pool drain]; i++; } @@ -744,6 +750,7 @@ NSString * const TURAnselServerPasswordKey = @"password"; [mServersPopUp selectItemAtIndex: 0]; [self disconnect]; [mExportMgr cancelExportBeforeBeginning]; + [threadPool drain]; } - (void)setStatusText: (NSString *)message withColor:(NSColor *)theColor -- 2.11.0