Java Community | Help. Code. Learn.JC|HCL
Java Community | Help. Code. Learn.โ€ข2y agoโ€ข
40 replies
Haiku

Under what conditions is Off-Heap memory worth it?

What I've read about the off-heap memory interfaces like ByteBuffer and the FFMI make it sound like it's much harder to access than heap memory and incurs a significant performance penalty. But they also neglect to mention the cases where the penalty is mitigated or the trade-off is worth it.

So I wanted to ask: under what circumstances is moving something off the heap beneficial?
- Does it specifically have to be something that's rarely accessed, or can it be relatively often?
- Does the type of data matter, or can you store most objects there without issue? Which types are better?
- What is the performance penalty from storing objects off the heap? Is it just "if it will never be GC'd, you can put it off heap", or is it only useful in certain situations?

Basically, what types of memory are good candidates for being moved off the heap?
Was this page helpful?