MemorySegment and Arena
Allocate off-heap memory.
Off-Heap Memory
FFM models native, off-heap memory with two central types: MemorySegment represents a contiguous region of memory, and Arena controls its lifetime.
Together they replace the unsafe manual buffer management of the past.
What Is a MemorySegment
A MemorySegment is a typed window over a block of memory. It knows its size and its lifetime, and every access is bounds-checked.
Segments can be off-heap (native) or wrap an on-heap array.
All lessons in this course
- Why FFM over JNI
- MemorySegment and Arena
- Downcall Handles
- Layouts and Structs