This is hard to explain but hopefully I can articulate my problem well enough.
I am working on a iOS project with several levels and each level will contain up to 40 full screen images on screen at any one time, but 98% of each image is transparent and together they create one image. Each image is 640 X 960 PNG. The only way I can align these accurately is to have them all the full res as I can’t set a location for each one.
When the app is loaded the images can easily take up over 130mb of memory. This seems crazy when the image should really only take 1-2mb in total.
Obviously I need all images to be loaded as separate UIImageViews as the app needs to reveal each image over time. i.e. they are hidden when loaded and are unhidden as the user interacts with the screen.
I have the app fully operational but I am wondering if someone might have some ideas as to a way that I can do this that will use much less memory.
I look forward to hearing some ideas.
40 * ~2mb is pretty close to 130mb.
Either compute a final image ahead of time so that you’re not storing them simultaneously, or find a way to lazy-load them on-demand. Also consider using tiled graphics.