Strange texture memory size.

Hi,

I’m loading a 480x320 PNG file and when it loads into memory in the game with display.newImageRect and when I measure how much texture memory I spent, it shows more than 1 MB!

Why it’s so big in the memory?!

Thanks. [import]uid: 206803 topic_id: 34424 reply_id: 334424[/import]

The texture memory issue is covered here:

http://www.coronalabs.com/blog/2012/04/25/faq-wednesday-2/

One thing the FAQ leaves out though - the memory calculation in the FAQ needs to be multiplied by 4 – since each pixel contains one byte of red, green, blue AND alpha. [import]uid: 79933 topic_id: 34424 reply_id: 136776[/import]

Thanks, this is perfect for this question:
http://wiki.sparrow-framework.org/tutorials/texture_formats_best_practices

So I have to use atlases, right?

One more thing, what’s the preferred memory size that I have to consider both iOS and Android? [import]uid: 206803 topic_id: 34424 reply_id: 136804[/import]

Not necessarily. A lot of people say you can safely use up to 24 MB of texture memory and run on most older iOS and Droids. Just being careful of the exact pixel dimensions of your art (keeping them below POT thresholds), careful loading/releasing of images (so only the minimum you need for whats onscreen is loaded), re-using everything you can, etc, might be enough – it really depends on your app.

Corona’s equivalent of the Atlases are Spritesheets, where you pack multiple images into one. There’s limitations on that too though, in that devices have a maximum size they allow, such as 2048x2048 pixels size, or it won’t load into texture memory. I didn’t need to use spritesheets for my app, so can’t really give you more info on them. [import]uid: 79933 topic_id: 34424 reply_id: 136807[/import]

Thanks for the reply. I think I don’t bother with spritesheets for now and revert to them if I hit into any problems, “KISS”-ing it. [import]uid: 206803 topic_id: 34424 reply_id: 136809[/import]

The texture memory issue is covered here:

http://www.coronalabs.com/blog/2012/04/25/faq-wednesday-2/

One thing the FAQ leaves out though - the memory calculation in the FAQ needs to be multiplied by 4 – since each pixel contains one byte of red, green, blue AND alpha. [import]uid: 79933 topic_id: 34424 reply_id: 136776[/import]

Thanks, this is perfect for this question:
http://wiki.sparrow-framework.org/tutorials/texture_formats_best_practices

So I have to use atlases, right?

One more thing, what’s the preferred memory size that I have to consider both iOS and Android? [import]uid: 206803 topic_id: 34424 reply_id: 136804[/import]

Not necessarily. A lot of people say you can safely use up to 24 MB of texture memory and run on most older iOS and Droids. Just being careful of the exact pixel dimensions of your art (keeping them below POT thresholds), careful loading/releasing of images (so only the minimum you need for whats onscreen is loaded), re-using everything you can, etc, might be enough – it really depends on your app.

Corona’s equivalent of the Atlases are Spritesheets, where you pack multiple images into one. There’s limitations on that too though, in that devices have a maximum size they allow, such as 2048x2048 pixels size, or it won’t load into texture memory. I didn’t need to use spritesheets for my app, so can’t really give you more info on them. [import]uid: 79933 topic_id: 34424 reply_id: 136807[/import]

Thanks for the reply. I think I don’t bother with spritesheets for now and revert to them if I hit into any problems, “KISS”-ing it. [import]uid: 206803 topic_id: 34424 reply_id: 136809[/import]