I've recently faced some memory managing issue in my app.
The application takes advantages of some high-quality images and this extremely increases memory usage.
Here are some informations about the project and images details to make the issue more clear :
There are around 90 images added to my project. Half of them are designed in @2x size to support The New iPad Retina Display. So the maximum number of images for each devices is around 45.
Total size of Retina version of all images is around 25 MegaBytes ( Size of each indivisual image is variable from 10 KBs to 6.8 MB ). Meanwhile, size of all standards images equals to 11 MegaBytes.
The size of XCode archive of the project equals to 44 MegaBytes.
Maximum resolution of indivisual images in standard version of images is around 1500x4000 px while the minimum is around 60x60 px.
Maximum resolution of indivisual images in Retina version of images is around 3000x8000 px while the minimum is around 120x120 px.
Retina version of images have "@2x~ipad" suffix in their name while the name suffix for the others is "~ipad".
There's only one instance of most images is created during the app lifecycle.
Around 25 of the images are loaded during app launch and the rest are loaded during gameplay.
I've used [UIImage imageNamed:@"image_name.png"] wherever I want to load an image ( using [UIImage imageWithContentsOfFile] and [UIImage imageWithData] was extremely inefficient ).
But here is there problem :
When I trace the memory usage using Instruments I see that app's memory usage is extremely high. Here are the statistics of memory allocation's in different situations :
Allocated Memory on iPad 2 using standard images at startup : 58 MB
Allocated Memory on iPad 2 using standard images during Gameplay (when all images are loaded) : 131 MB
- Allocated Memory on New iPad using Retina images at startup : 211 MB
- Allocated Memory on New iPad using Retina images during Gameplay (when all images are loaded) : 470 MB
Any ideas why allocated memory is a lot higher than total size of images ?