A question about glDeleteTextures

Member
Posts: 34
Joined: 2009.01
Post: #1
Hello happy coders !

I'm working on a game with lots of png textures and I'm experiencing crashes because I'm running out of memory.
I use code similar to GLSprite to load a png, and use glDeleteTextures when I don't need the texture anymore.
With Instruments I can see memory usage is increasing at load time but is not decreasing when I delete textures.
Is there something more to do when deleting textures ?
Is there a way to check memory usage when running on a device i.e. without Instruments ?

Thanks
Quote this message in a reply
Member
Posts: 25
Joined: 2009.05
Post: #2
Fred9000 Wrote:Hello happy coders !

I'm working on a game with lots of png textures and I'm experiencing crashes because I'm running out of memory.
I use code similar to GLSprite to load a png, and use glDeleteTextures when I don't need the texture anymore.
With Instruments I can see memory usage is increasing at load time but is not decreasing when I delete textures.
Is there something more to do when deleting textures ?
Is there a way to check memory usage when running on a device i.e. without Instruments ?

I have seen a similar topic somewhere.
Make a loop that will create and destroy same texture many times, and watch for memory usage.
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #3
ShiftZ Wrote:I have seen a similar topic somewhere.
Make a loop that will create and destroy same texture many times, and watch for memory usage.

Hello ShiftZ

I did. Memory doesn't seem to increase with a single texture. But, according to Instruments, memory is allocated 3 times :
one time with gldGetTextureLevelImage, another with gfxAllocateTextureLevel
and also with CoreGraphics img_data_lock.

So it could be quite huge for a 1024*1024 png texture !

My first game on AppStore : here
Quote this message in a reply
Member
Posts: 34
Joined: 2009.01
Post: #4
Actually it seems like loading a texture with :

spriteImage = [UIImage imageNamed:name].CGImage;

is caching the file, and using memory.

It's better to use :

NSData *texData = [[NSData alloc] initWithContentsOfFile:path];
UIImage *image = [[UIImage alloc] initWithData:texData];
spriteImage = image.CGImage;

My first game on AppStore : here
Quote this message in a reply
Post Reply