iPhone - UIImage imageScaledToSize Memory Issue

Posted by bbullis21 on Stack Overflow See other posts from Stack Overflow or by bbullis21
Published on 2009-09-14T22:47:09Z Indexed on 2010/06/18 8:03 UTC
Read the original article Hit count: 495

I have done research and tried several times to release the UIImage memory and have been unsuccessful. I saw one other post on the internet where someone else was having this same issue. Everytime imageScaledToSize is called, the ObjectAlloc continues to climb.

In the following code I am pulling a local image from my resource directory and resizing it with some blur. Can someone provide some help on how to release the memory of the UIImages called....scaledImage and labelImage. This is the chunk of code where the iPhone Intruments has shown to have the ObjectAlloc build up. This chunk of code is called several times with an NSTimer.

//Get local image from inside resource
NSString * fileLocation = [[NSBundle mainBundle] pathForResource:imgMain ofType:@"jpg"];
    NSData * imageData = [NSData dataWithContentsOfFile:fileLocation];
    UIImage * blurMe = [UIImage imageWithData:imageData];

//Resize and blur image
    UIImage * scaledImage = [blurMe _imageScaledToSize:CGSizeMake(blurMe.size.width / dblBlurLevel, blurMe.size.width / dblBlurLevel) interpolationQuality:3.0];
    UIImage * labelImage = [scaledImage _imageScaledToSize:blurMe.size interpolationQuality:3.0];
    imgView.image = labelImage;

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-management