Justin Galzic
Justin Galzic

Reputation: 3971

Does UIImage's imageNamed still cause memory issues on iOS4 for large images?

I found a couple of Memory Management articles that mentioned UIImage's imageNamed causing problems when you have a lot of large images in memory.

http://akosma.com/2009/01/28/10-iphone-memory-management-tips/ http://www.alexcurylo.com/blog/2009/01/13/imagenamed-is-evil/

Both of these were written for OS version <= 3.0.

Does anyone know if these are still a problem in iOS 4?

Upvotes: 2

Views: 1698

Answers (3)

Add080bbA
Add080bbA

Reputation: 1876

it does. In combination with UIPageViewController, definitely it does. trying to build a kids application displaying animal's sound and cartoon keyFrame animation all individual animal details are in their own UIViewController All views are displayed in UIPageViewController (Transition:scroll). Didn't know about imageNamed bug and for nearly a month , thought it was a problem caused by UIPageViewController. Memory was never being released by ARC. ASA i switched to imageWithContentsOfFile instead of imageNamed, all problems solved. UIPageViewController was innocent in real. It works smooth now. No unreleased memory problem.

Upvotes: 0

Bdebeez
Bdebeez

Reputation: 3552

If you look at this link: Dispelling the UIImage imageNamed: FUD you'll see there are really two problems with large images and imageNamed:

  1. Prior to iOS 3.0 was a bug in the caching routines of imageNamed: such that it would not let go of its cache even when it received a mem warning. This was a pretty major issue and was the source of a lot of memory crashes for me personally, as there's no way you could get memory back after using imageNamed: to load it. This is NOT an issue anymore, as this seems to have been fixed in 3.0.
  2. imageNamed: keeps, in its cache, the uncompressed image data itself. For really large (in terms of their size on screen - width x height) images, this data can be really large. width * height * 4 is what I've commonly seen cited for its uncompressed size. This would still potentially be a problem for you if you are using rather large images - and is especially to be avoided if you don't need to redraw them often.

So to recap: 1 is no longer a problem, 2 might be.

Upvotes: 2

jbm
jbm

Reputation: 1492

No longer a problem, see here, and maybe here.

Upvotes: 3

Related Questions