Deleting GPU Textures Created by Nifty

Hello everyone. Can anyone explain how to remove textures uploaded to the GPU at the end of a screen?



In my app, I have two AppStates, both of which implement “ScreenController” and call “Nifty.fromXml” in their “initialize” methods to create the display for the application state. In the “cleanup” method of the first AppState I call “removeScreen”. This is sufficient to remove the screen from the view so that the view in the following application state is correct, but looking at the statistics view, I can see the textures were never deleted from GPU memory (the number of textures indicated is the number of textures used in both the first and second application states when in the second application state). If I was to do this enough times (with enough different textures) the GPU memory would fill up, so I need to fix this.



I spent all day working on this, and researching the problem, including searching the forum, but the semi-related information I found wasn’t enough. I apologize in advance if this has already been answered.

Actually, the textures would be removed at some point. jME3 keeps them cached for a while in case they might be used again.