Roray FFM Utils Quickstart
Get started with high-performance memory management in 5 minutes.
Prerequisites
- Java 24+ with preview features enabled
- Gradle 8.5+ or Maven 3.9+
Installation
Add to your build.gradle.kts:
dependencies {
implementation("express.mvp.roray:roray-ffm-utils:0.1.0-SNAPSHOT")
}
Quick Example
Memory Segment Pool
Efficiently allocate and release off-heap memory:
;
;
// Create a pool with 64 segments of 4KB each
var pool ;
// Borrow a segment (zero-allocation after warmup)
MemorySegment segment ;
try finally
Zero-Copy String Handling
Work with UTF-8 strings without allocating:
;
// Wrap a memory region as a UTF-8 view
Utf8View view ;
// Compare strings without allocation
if
// Convert to String only when needed
String str ;
JVM Arguments
Enable FFM preview features:
For Gradle:
tasks.withType<JavaCompile> {
options.compilerArgs.add("--enable-preview")
}
tasks.withType<JavaExec> {
jvmArgs("--enable-preview", "--enable-native-access=ALL-UNNAMED")
}
Next Steps
- User Guide - In-depth patterns and best practices
- API Reference - Complete API documentation
- Benchmarks - Performance comparisons