Hacker News new | ask | show | jobs
by StreamBright 3028 days ago
If you want to keep data off heap you need to use sun.misc.Unsafe and allocate / free by yourself. I guess it is called unsafe for a reason. With G1GC you can do magical things to reduce the GC overhead which I always recommend as the first step before trying off heap.
2 comments

ByteBuffer.allocateDirect is another off-JVM-heap solution that's not marked unsafe.
You don't even have to go through Unsafe. ByteBuffer.allocateDirect() gives you a chunk of off-heap memory.