TypedMemory
Typed off-heap memory for Java 25 and greater.
TypedMemory is a Java library for working with contiguous off-heap memory through strongly typed views. It builds on the Java Foreign Function & Memory (FFM) API and lets you map Java record types onto native memory with a simple, expressive API.
Instead of manually managing layouts, offsets, and low-level access patterns for every structure, TypedMemory gives you a type-safe abstraction over memory while still preserving the low-level control needed for systems, interop, graphics, simulation, and data-oriented programming.
import module com . mamba . typedmemory ; record Point ( float x , float y ) {} void main () { try ( Arena arena = Arena . ofConfined ()) { Mem < Point > points = Mem . of ( Point . class , arena , 10 ); points . set ( 0 , new Point ( 5 , 3 )); Point point = points . get ( 0 ); IO . println ( point ); } }
Why TypedMemory?
Working directly with raw memory in Java is powerful, but often verbose and repetitive.
TypedMemory aims to make off-heap programming feel more natural by providing:
Strongly typed views over contiguous memory
over contiguous memory Record-based schemas for describing structured data
... continue reading