Unforunately jME leaves most cleanup stuff for the user. You will be required to manually cleanup textures, fbos, shaders, vbo etc. However it is possible to integrate this cleaning automatically with the garbage collector…
I would suggest you call "shaders.clear();", when you hit 2 . This will delete all objects in your array list.
Thank you for the reply, JackNeil.
That was my mistake when uploading the test code.
(I modified the test code to post it and made a mistake. sorry.)
Actually my local version calls shaders.clear() when hit '3';
But It doesn't helps at all.
Unforunately jME leaves most cleanup stuff for the user. You will be required to manually cleanup textures, fbos, shaders, vbo etc. However it is possible to integrate this cleaning automatically with the garbage collector..
I understand the need for the user to release resources.
(It would be inconvenient, but fast and optimized memory management is possible by that)
How could I release shader?
shader object isn't garbage collected as far as I know from the experience.
Because these data are natively allocated, explicit cleanup method call seems to be needed like GC(Graphics Context)
Do I have to use LWJGL/JOGL directly?
I think it would be very useful to have release method in jme.
Or are there already cleanup methods for the shader object?
Have you tried calling clearAttributes() and clearUniforms()?
What a quick reply!! I appreciate it.
But as you can see.
The shader code above is so simple and doesn't have any uniform, attributes.
And according to the inspection of GLSLShaderObjectState class,
it clears not native resources but just object references.
It means if there is no reference to the GLSLShaderObjectStates object,
it is garbage collected and no need to calll clearAttribtes(), clearUniforms().
I'm afraid I'm wrong,
but in my opinion it seems to be native resource management issue.
I modified jme and called LWJGLShaderObjectState.removeFragShader(), removeVertShader()
but it doesn't help either.
My feeling is that resource handling and cleanup is jME's single biggest weakness - for most or all types not just shaders.
However I have not yet got to the stage of taking a really good look at it or trying to do anything about it. So maybe I'm wrong.
Agreed. I have done some research about resource handling and have a rather good solution. jME3 will definitely have a universal resource management system.