www.jpct.net

jPCT-AE - a 3d engine for Android => Bugs => Topic started by: Thomas. on April 14, 2012, 06:05:37 pm

Title: Memory and replace texture
Post by: Thomas. on April 14, 2012, 06:05:37 pm
When I use Texture.replaceTexture() method, original is probably still in memory. Can someone confirm it?

I have textures 512*512 and when is all replace by 128*128 memory increased to 42MB, before it was 35MB
Title: Re: Memory and replace texture
Post by: EgonOlsen on April 14, 2012, 07:57:57 pm
Of course it is. That why the docs say:

Quote
...It might be required to call unloadTexture() before to ensure that the old texture has been unloaded from the GPU in case it's no longer used somewhere else.

 ;)
Title: Re: Memory and replace texture
Post by: Thomas. on April 14, 2012, 08:31:35 pm
Oh ;D ... I tried this, after everything are without texture

edit: now it is OK :)

Code: [Select]
Texture texture = tm.getTexture(name);
TextureManager tm = TextureManager.getInstance();
tm.unloadTexture(fb, texture);
tm.replaceTexture(name, newTexture);

before I remove old and add new texture

edit2: Allocated memory does not increased, but still same...?
Title: Re: Memory and replace texture
Post by: EgonOlsen on April 14, 2012, 11:16:23 pm
edit2: Allocated memory does not increased, but still same...?
I don't understand... ???
Title: Re: Memory and replace texture
Post by: Thomas. on April 15, 2012, 01:04:43 am
Allocated memory is not released, when I replace textures by much more smaller.
Title: Re: Memory and replace texture
Post by: EgonOlsen on April 15, 2012, 08:15:18 pm
Of course not. The VM doesn't release memory to the OS. If just frees internal VM memory. If you aren't holding a reference to this texture anymore, it will be garbage collected. No one else holds a reference to it in jPCT-AE. The engine only deals with IDs, it doesn't keep reference to the textures (with the exception of the TextureManager of course).