How do I properly dereference a buffer?
<p>I am having some memory problems with a project of mine. After a bit of tracing memory on several positions in my program, I retraced the problem to this line:</p>

<pre><code>(FloatBuffer)lightBuffer.asFloatBuffer().put(lightAmbient).flip()
</code></pre>

<p>I am using the resultant buffer in a function straight away, but it seems that that float buffer is not emptied after it has been used. 
So how do I properly empty/dereference a buffer in java? </p>

<p>ps: I tried the clear() method, but according to the java documentation that only resets the buffer; it does not remove the data from it.</p>
