Memory and replace texture

Started by Thomas., April 14, 2012, 06:05:37 PM

Previous topic - Next topic

Thomas.

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

EgonOlsen

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.

;)

Thomas.

#2
Oh ;D ... I tried this, after everything are without texture

edit: now it is OK :)

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...?

EgonOlsen

Quote from: Thomas. on April 14, 2012, 08:31:35 PM
edit2: Allocated memory does not increased, but still same...?
I don't understand... ???

Thomas.

Allocated memory is not released, when I replace textures by much more smaller.

EgonOlsen

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