fuzzygoat
fuzzygoat

Reputation: 26223

UIImageView memory usage

When animating a number of frames using UIImageView how does iOS map them into memory, is it simply image resolution x bit depth (i.e. a 200x200 24bit TGA will be the same as a 200x200 24bit JPG) or does iOS take into account unused alpha pixels in the image. Also how does this work with images loaded into the Xcode project (and maybe not used) and those that are directly loaded into memory (i.e. using UIImage imageNamed: from within the app)?

Upvotes: 0

Views: 584

Answers (1)

Andrea
Andrea

Reputation: 26383

I think that even if the image is 24 bit it will decompress to 32bit, because the default color space is 4channels, the size usually is the number_of_pixel_in_row*number_of_pixel_in_height*byte_for_pixels. In my tests I always saw the same memory consumption even for different formats. Images are loaded lazily at the time they need to be drawn in a context, after that if not released they keep the memory pressure.That means that even if you create an UIImage object it won't be decompressed until it needs to be drawn . Methods such as -imageNamed caches the images in memory, I usually use it only for repetitive images.
Hope this helps

Upvotes: 1

Related Questions