I have this piece of code:
And here is my code for the "saveImageAsJPGFile" function:
Although static analysis does not give me any errors, the folowing appears on the console log:
However, I can't say why this is happening. Putting nslogs after each variable created and each process done shows that before the [internalPool drain] every variable has a retain count of 1.
Can anyone help me on this?
Code:
- (void)processAndSaveImageWithID:(NSString *)imageID
{
NSString *imagesDirectory = ...
NSString *mediumImagesDir = ...
NSAutoreleasePool *internalPool = [[NSAutoreleasePool alloc]init];
NSLog(@"processing Image with ID");
UIImage *img = [[UIImage alloc]initWithContentsOfFile:[imagesDirectory stringByAppendingPathComponent:imageID]];
UIImage *mediumImage = [img scaledImage:428];
[img release];
[sharedGlobals saveImageAsJPGFile:mediumImage withQuality:0.6f withFileID:imageID toDirectory:mediumImagesDir];
UIImage *shrinkedImage = [mediumImage scaledImage:100];
[B] [sharedGlobals saveImageAsJPGFile:shrinkedImage withQuality:0.6f withFileID:imageID toDirectory:sharedGlobals.applicationThumbnailsDirectory]; //THIS CAUSES THE ERROR!!![/B]
self.imageView.image = shrinkedImage;
[self applyChangesGloballyWithFileID:imageID];
[self.imageNameTextField setEnabled:YES];
imageNameTextField.userInteractionEnabled = YES;
imageNameTextField.hidden = NO;
takePictureButton.userInteractionEnabled = NO;
[internalPool drain];
}
And here is my code for the "saveImageAsJPGFile" function:
Code:
- (void)saveImageAsJPGFile:(UIImage *)image withQuality:(CGFloat)quality withFileID:(NSString *)fileID toDirectory:(NSString *)dir
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSLog(@"saving image to %@", dir);
[UIImageJPEGRepresentation(image, quality) writeToFile:[dir stringByAppendingPathComponent:fileID] atomically:NO];
[pool drain];
}
Although static analysis does not give me any errors, the folowing appears on the console log:
Code:
009-09-19 14:22:45.325 iMe[6058:5607] saving image to /Users/soulstorm/Library/Application Support/iPhone Simulator/User/Applications/2B74F5DD-A743-484D-92EB-5C9449600C44/Documents/thumbnails
iMe(6058,0xb0103000) malloc: *** error for object 0x188e000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
However, I can't say why this is happening. Putting nslogs after each variable created and each process done shows that before the [internalPool drain] every variable has a retain count of 1.
Can anyone help me on this?