Tech

Java 25 library TypedMemory simplifies off-heap memory management for systems programming

Developers can now map Java records to contiguous native memory with a simple API, though the project remains in an evolving phase with potential breaking changes

Author
Owen Mercer
Markets and Finance Editor
Published
Draft
Source: Hacker News · original
Tech
No image available
New tool from mamba-studio offers type-safe abstraction over native memory without replacing the Foreign Function & Memory API

A new library called TypedMemory has been released for Java 25, designed to streamline the process of mapping Java records to strongly typed off-heap memory. Developed by mamba-studio, the tool leverages the Foreign Function & Memory (FFM) API to provide a type-safe abstraction for working with contiguous native memory. This approach aims to simplify complex systems programming tasks, including interoperability, graphics, and data-oriented work, without discarding the foundational capabilities of the underlying FFM API.

Working directly with raw memory in Java is traditionally powerful but often results in verbose and repetitive code. TypedMemory addresses this by allowing developers to map Java record types onto native memory using a simple, expressive API. This eliminates the need to manually manage layouts, offsets, and low-level access patterns for every structure, making off-heap programming feel more natural and direct while preserving the necessary low-level control required for high-performance applications.

The project is built using Maven and is available on Maven Central, enabling developers to include it directly in their project pom.xml files. For applications utilising the Java module system, specific configuration is required within the module-info.java file to ensure proper integration. The library is licensed under the Apache License 2.0 and is specifically targeted at Java 25 and greater versions.

While the core API is currently usable, the project is explicitly described as evolving. The design is still being refined, which means the library may introduce breaking changes as it matures. Consequently, claims regarding its stability should be treated with caution, and it is not yet considered a final stable product ready for critical systems without further testing.

The primary goal of TypedMemory is to bridge the gap between Java data definitions and low-level memory representations. By using records as a natural schema-like model for structured memory, the library makes low-level Java memory programming feel typed and practical. It does not attempt to replace the FFM API but rather enhances it by providing a higher-level view that makes it easier to inspect and reason about the actual structure stored off-heap.

Feedback, issues, and suggestions are welcomed by the maintainers, with contributions and discussion highly appreciated as the project continues to develop. The release marks a significant step toward making systems programming in Java more accessible, though users are advised to monitor the project for updates regarding its evolving architecture.

Continue reading

More from Tech

Read next: Apple opens developer access to iOS, iPadOS and macOS 27 betas
Read next: Apple confirms macOS 27 Golden Gate requires Apple Silicon, ending Intel support
Read next: Apple unveils watchOS 27 with Siri AI integration and hardware restrictions