I ran into this problem: suppose I have a method that gets called a few times every frame at about 100fps. Inside this method I create a new Vector3 object. The Vector3 class is my own personal implementation, and contains a private FloatBuffer.
public class Vector3
private FloatBuffer mBuffer = BufferUtils.createFloatBuffer( 3 );
I use that float buffer to store the x y and z coordinates and to quickly return them if I need to use the vector with the opengl api.
The problem is, the garbage collector is having a hard time cleaning up my Vector3 objects, so with only that initial method creating one Vector3 object, my memory consumption skyrockets to about 500mb ( it normally only uses 40mb ). Reading about ByteBuffers on the javadoc page, I see they are treated specially from the memory point of view. They also recommend "It is therefore recommended that direct buffers be allocated primarily for large, long-lived buffers".
Is there a nice way to convert from vectors ( and matrices ) to FloatBuffers ?