0Pricing
Java Academy · Lesson

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

  1. Why FFM over JNI
  2. MemorySegment and Arena
  3. Downcall Handles
  4. Layouts and Structs
← Back to Java Academy