What is the best practice to load a lot of large images?
Our app is crashed (on iPhne 4s and on iPad Mini) when I try to load ~60 jpg (960x640, total ~13M) images.
Background:
US History is an educational app, made with Titanium 4 years ago (it was selected as a Staff Favorite!
).
Main features are events, timelines and quiz and all of them use large images.
Thank you for your help in advance.
Comments
I define a Scene.setup() function to preload images.
640*960 image is loaded to memory as 1024*1024
The size of this image: 4*1024*1024 = 4Mb
60 image size = 60 * 4Mb = 240Mb of RAM
It is crashed in device with 256Mb of RAM
Likes: SinisterSoft, bali001
In case of slideshow I will try to load images on demand: I made some modification in AceSlide.lua earlier so I have an "afterChange" event. After the slide change is finished I will release image on the "oldest" slide and load another one on the "newest".
But in timeline mode I need all of them. If there is no other way, I will resize the images.
If you intend to show all your image at once on the screen, obviously you will have to scale them down so that they all fit. If this is the case, you could consider allocating a RenderTarget and rendering a scaled down version of each image to it, one a a time. Your RenderTarget could be then used as a texture atlas.
On the other way, if you intend to show them full scale in scene larger than the screen, you could only keep in memory images that are actually displayed and those that would be displayed if the user moves a little, discarding images not in view. Maybe think the scene like a tile map. This may lag during a move but may be worth the trick.
Hope this helps
In my game No Brakes I initially capture a nice screenshot of all levels and show them in AceSlide. This worked well up to about 15 images, after that I started getting low memory warnings, especially on the iPod.
I ended up, quite painstakingly indeed, manually creating a bitmap for each track, then load them from the library instead. This cut the initialisation time of AceSlide in half, as well as consumed a lot less memory.
Niclas
https://deluxepixel.com
Likes: SinisterSoft
I will try these suggestions
Edit:
I will optimize image resolutions first. I will downscale them to 512x768 from 640x960