2

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?

Justin Galzic
  • 3,951
  • 6
  • 28
  • 39

3 Answers3

3

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

Community
  • 1
  • 1
jbm
  • 1,482
  • 11
  • 26
2

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.

Community
  • 1
  • 1
Bdebeez
  • 3,542
  • 3
  • 31
  • 32
  • This is because each pixel has four bytes: alpha, red, green, blue. width * height gives you the number of pixels. – orkoden Oct 04 '13 at 12:21
0

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.

Add080bbA
  • 1,818
  • 1
  • 18
  • 25