You may remember my previous post abour garbage creation
http://www.java-gaming.org/forums/index.php?topic=10837.0.
One of the answer was that part of the generated garbage will disapear with the JSR.
I have now moved to JSR beta 1 and run a memory profiling. It appears that it is worst than before ; all functions like glVertexPointer now call checkArrayVBODisabled which call checkBufferObject which creates an int[1] (16 octets) each time in order to make a call to glGetInteger.
When this is multiplied by the number of batches times the number of arrays, it ends up creating quite a lot of garbage per frame.
This could be easily solved by having a function like the one in LWJGL ;
private static final IntBuffer int_buffer = BufferUtils.createIntBuffer(16);
/**
* Obtain a GL integer value from the driver
*
* @param gl_enum The GL value you want
*
* @return the integer value
*/
public static int glGetInteger(int gl_enum) {
GL11.glGetInteger(gl_enum, int_buffer);
return int_buffer.get(0);
}
Or this could be optimized in the internals of the com.sun.opengl.impl.GLImpl.checkBufferObject method.
Vincent
Note : for people interested, I have tried both options stated in my previous post (lowering garbage creation & managing part of my memory directly from java). I ended up using the second option with a simple implementation of object pools + reference count + pre-allocation profile. It gives very good result and have very little impact on the overall library design. Lowering garbage collection as a general rule was very difficult to implement whithout degrading the quality of the library (mainly cache & synchronization problems).