UIButton setBackgroundImage consumes doesn't release memory?

Posted by just_another_coder on Stack Overflow See other posts from Stack Overflow or by just_another_coder
Published on 2010-05-06T05:33:00Z Indexed on 2010/05/06 5:38 UTC
Read the original article Hit count: 191

Filed under:
|

My UIButton has it's background image set like this:

[myImageButton setBackgroundImage:[UIImage imageNamed:myImageName] forState:UIControlStateNormal];

myImageButton is a retained property of the class, and is setup with IB. No where else is it accessed in the app.

myImageName is simply an NSString with a filename like @"myImage_number_1.png"

I am loading large images, 1024 x 1024 in size. When the view is shown, it changes the image with the above statement, then available memory decreases.

After I see the view about 7-9 different times, the app crashes with a memory warning.

I thought the method would free up the loaded image.

The view itself is only instantiated and allocated one time, so it's not in the retain/release cycle if the view controller.

Is there something about this setBackgroundImage I don't know that causes it to not release memory?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ipad