Texture Memory Question

I’ve recently discovered the invaluable:

[lua]local memoryUsed = function()
print("Texture memory used: " … system.getInfo(“textureMemoryUsed”))
end

memoryUsed();[/lua]

But wanted to ask something about it.

If I load a 64kb sprite sheet, I get:

Texture memory used: 524288

524288 / 1000 = 524kb ( think I’ve got that right)

Why does a 64kb sprite sheet balloon to 524kb?

Thanks

Tom
[import]uid: 55068 topic_id: 10973 reply_id: 310973[/import]

Maybe is because there are other apps using Texture memory. To ensure that your sprite uses the correct amount of memory, just use the memoryUsed() function before and after the load of the sprite, and compare the values. [import]uid: 14235 topic_id: 10973 reply_id: 39926[/import]

Hmmm…

Here’s my code:

[lua]local memoryUsed = function()
print("Texture memory used: " … system.getInfo(“textureMemoryUsed”))
end

memoryUsed();

require “sprite”

local zombie1 = sprite.newSpriteSheetFromData( “z1.png”, require(“z1”).getSpriteSheetData() )

local spriteSet = sprite.newSpriteSet(zombie1,1,25)

sprite.add(spriteSet,“walk”,1,25,1000,0)

local zombie = sprite.newSprite(spriteSet)

zombie:prepare(“walk”);
zombie:play();

zombie.x = 100
zombie.y = 100;

memoryUsed();[/lua]

And here’s the output:
Texture memory used: 0
Texture memory used: 524288

The png is 61kb.

I am reading it right, aren’t I? It’s using over half a meg of texture memory?

Thanks

Tom [import]uid: 55068 topic_id: 10973 reply_id: 39931[/import]

This thread sheds some light on the subject:

http://developer.anscamobile.com/forum/2011/03/05/texture-memory-not-correct

“The texture memory used in Corona (and iOS and Android) is an umcompressed bitmap of the loaded image. Each pixel requires 32 bits (4 bytes)”

I get it now. :slight_smile:

Thanks

Tom [import]uid: 55068 topic_id: 10973 reply_id: 39933[/import]