Assume in one hand we have a direct byte buffer created with env->NewDirectByteBuffer(). In other hand we have similar direct buffer, but created with ByteBuffer.allocateDirect(). Obviously both these objects should be managed by JVM in the same manner, including management of the backing native buffer, which in first case was provided by user, and in second case was allocated by JVM from native heap.
Of course JVM must free backing buffer during GC'ing of the second object (instantiated with ByteBuffer.allocateDirect()).
And my question: Will JVM try to deallocate buffer during GC'ing of the first object (instantiated with env->NewDirectByteBuffer()) ?
P.S. I've not found clear answer neither at JNI docs neither at SO. The most helpful info was here http://www.ibm.com/developerworks/library/j-nativememory-linux/index.html :
Direct ByteBuffer objects clean up their native buffers automatically but can only do so as part of Java heap GC — so they do not automatically respond to pressure on the native heap.
So it seems like JVM will free backing buffers during GC pass, but there is no any mentions about deallocator. Is it plain free() or something else.