I'm reading the article here: http://www.kdgregory.com/?page=java.byteBuffer
On that page, there is this section:
In fact, the only reason that I can see for using direct buffers in a pure Java program is that they won't be moved during garbage collection. If you've read my article on reference objects, you'll remember that the garbage collector compacts the heap after disposing of dead objects. If you have large blocks of heap memory allocated as buffers, they may get moved as part of compaction, and no matter how fast your CPU, that takes time; it's not something you want to do on every full collection. Since the direct buffer lives outside of the heap, it isn't affected by collections. On the other hand, every data access is a JNI call. Only benchmarking will tell you whether this helps or hurts your particular application.
The JNI statement implies there is a drawback to using JNI, but I'm unsure what it is. Can anyone help? I did find this question on stack overflow: Disadvantages of using Java Native Interface
However, I didn't believe from the context of the statement in that paragraph the author implied that the drawback was that JNI was difficult to debug or that it could take down the jvm. Thanks!