Login  Register

Re: glDeleteBuffers Very Inconvenient.

Posted by gouessej on Jan 23, 2013; 12:44am
URL: https://forum.jogamp.org/glDeleteBuffers-Very-Inconvenient-tp4027988p4027992.html

Hi

Garbage collection is not working very well with Java objects bound to "native" objects because they are allocated on different heaps. The garbage collection is only sollicited when there is not enough memory on the Java heap, not on the native heap. It is common to manually handle this kind of resources. You can release the native resources used by a direct NIO buffer so that you don't run out of memory. Object pooling is only efficient on objects that are very expensive to destroy in desktop environments but still very efficient on Android DVM because of its poor garbage collection.

There is no obvious solution in JOGL, Sven should just check that we don't keep any reference on unused NIO buffers. I will post a link to an extract of an article I wrote about memory management in a few hours, it might help you a bit.

You can queue some runnables in order to destroy OpenGL resources step by step, there are some solutions but their places are rather in middle level and high level APIs.

N.B: direct NIO buffers are no more page aligned in Java 1.7 by default.
Julien Gouesse | Personal blog | Website