HeadlinesBriefing favicon HeadlinesBriefing.com

TypedMemory brings typed off‑heap memory to Java 25

Hacker News •
×

The mamba‑studio team released TypedMemory, a library that maps Java record types onto contiguous off‑heap memory using the Foreign Function & Memory (FFM) API. By wrapping native MemorySegments in type‑safe views, developers can allocate, read, and write structures like Point or Color without hand‑crafting layouts. A simple arena‑based example demonstrates creating a 10‑element Point buffer and printing its first entry.

Unlike raw FFM usage, TypedMemory generates a MemoryLayout from the record definition, preserves alignment, and supports bulk operations such as fill, copy, and swap. It works with Java 25 or newer, requiring the --enable-native-access flag at runtime. The library ships on Maven Central as version 0.1.0, ready for inclusion in any Maven or module‑based project.

Current features include typed allocation, nested records, fixed‑size arrays, and reinterpretation of existing segments. Planned extensions aim at pointer‑typed fields and union support. Although still experimental and limited to Java 25+, TypedMemory offers a practical bridge between high‑level Java data models and low‑level native interop, making off‑heap programming more approachable for graphics, simulation, and data‑oriented workloads.