Texture Memory Question

I've recently discovered the invaluable:

1
2
3
4
5
local memoryUsed = function()
print("Texture memory used: " .. system.getInfo("textureMemoryUsed"))
end
 
memoryUsed();

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.

Hmmm...

Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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();

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. :-)

Thanks

Tom

views:1482 update:2011/9/29 19:21:19
corona forums © 2003-2011