--> Garbage Collection!
Using a Memory Profiler, it shows that your demo application allocates huge amounts of direct byte buffers every frame.
The following is a snapshot of your demo application's profile:
The timeline above is in m:ss.
Over the course of one minute of running time, it allocated over 3 million direct byte buffers:
Suggestions for improvement:
- don't allocate a direct byte buffer inside Matrix4f.toFloatBuffer() but have that method take a ByteBuffer/FloatBuffer as parameter and put the matrix elements array to it
- cache a single FloatBuffer maybe inside of your Shader class and have its setUniformMat4f() method pass that to the Matrix4f.toFloatBuffer(FloatBuffer)
- implement Matrix4f.toFloatBuffer(FloatBuffer) as:
public FloatBuffer toFloatBuffer(FloatBuffer fb){
fb.put(elements).flip();
return fb;
}