⚡ High-performance 32-byte SIMD-aligned off-heap memory allocation and page locking engine for Java.
FastMemory provides zero-GC off-heap memory management for the FastJava ecosystem. It allocates 32-byte and 64-byte aligned native RAM buffers for AVX2/AVX-512 execution and prevents Windows OS paging via physical RAM page locking (VirtualLock).
import fastmemory.*;
import fastpointer.Pointer;
public class Demo {
public static void main(String[] args) {
// Allocate 1024 bytes of 32-byte SIMD-aligned native memory
Memory memory = Memory.allocateAligned(1024, 32);
// Lock physical RAM pages to prevent OS swap
memory.lockPages();
// Get fast Pointer wrapper for address arithmetic
Pointer ptr = memory.pointer();
ptr.setInt(0, 42);
System.out.println("Allocated 32-byte aligned address: " + ptr);
System.out.println("Value at offset 0: " + ptr.getInt(0));
// Free memory
memory.free();
}
}- Key Features
- Real-World Use Cases
- Performance Benchmarks
- API Reference
- Installation
- Documentation
- Platform Support
- License
- ⏱️ 32-Byte / 64-Byte SIMD Alignment: Prevents hardware alignment penalties during AVX2 and AVX-512 vector instructions.
- 🔒 Physical Page Locking (
VirtualLock): Prevents critical screen capture, audio, and tensor buffers from being paged to disk. - 📦 Zero GC Overhead: Operates entirely outside the JVM Garbage Collector.
- 🚀 Pointer Integration: Native interoperability with
FastPointerandFastCore.
- 🛡️ HFT SIMD Memory Alignment: Allocate 32-byte SIMD-aligned off-heap buffers optimized for AVX2 and AVX-512 vector instructions.
- 🔒 OS Page Locking: Pin physical RAM pages to prevent OS memory swapping in latency-critical financial and game engine systems.
- 🚀 High-Throughput Off-Heap Caching: Manage massive off-heap data structures with zero Garbage Collection pause risk.
FastMemory provides high-throughput off-heap memory management. In the official JMH Benchmark, the system measured 32-byte SIMD-aligned off-heap allocation and raw memory access throughput:
Benchmark Mode Cnt Score Error Units
JMH_FastMemory.benchmarkAlignedAllocation thrpt 2 12450000.120 ops/s
12.45 Million Allocations per Second:
FastMemoryprovisions 32-byte SIMD-aligned off-heap buffers with zero Garbage Collector pause risk.
Memory.allocate(long bytes): Allocates default 32-byte aligned native off-heap memory.Memory.allocateAligned(long bytes, int alignment): Allocates memory aligned to specified boundary (16, 32, 64 bytes).pointer(): Returns aPointerinstance pointing to the allocated address.address(): Returns the primitivelongmemory address.lockPages()/unlockPages(): Locks or unlocks physical RAM pages viaVirtualLock.free(): Releases the allocated native memory back to the OS.
Add the JitPack repository and the mandatory FastCore dependency to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastMemory Library -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastMemory</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastPointer (Required for pointer operations) -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastPointer</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastCore (Mandatory Native Loader) -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.1</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastMemory:0.1.1'
implementation 'com.github.andrestubbe:FastPointer:0.1.0'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- 📦 fastmemory-0.1.0.jar (The Core Library)
- 🎯 fastpointer-0.1.0.jar (Required for pointer operations)
- ⚙️ fastcore-0.1.0.jar (The Mandatory Native Loader)
See the examples/ directory for interactive technical implementations and official JMH benchmarks:
| Benchmark Case | Description | Java Example | JMH Benchmark |
|---|---|---|---|
| 32-Byte Aligned RAM | 32-byte SIMD-aligned off-heap allocation vs Heap arrays | Demo.java | JMH_Memory.java |
run-benchmark.bat- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API descriptions, border configurations, and codepoint index.
- PHILOSOPHY.md: The engineering rationale for zero-allocation performance.
- ROADMAP.md: Future milestones and planned features.
| Platform | Status |
|---|---|
| Windows 10/11 (x64) | ✅ Fully Supported |
| Linux (x64 / ARM64) | 🚧 Planned |
| macOS (Apple Silicon) | 🚧 Planned |
- FastPointer — Zero-overhead native address arithmetic
- FastSIMD — Hardware vector acceleration engine (AVX2, AVX-512, NEON)
- FastSharedMemory — Ultra-fast zero-copy IPC and shared memory mapped files
- FastCore — Native JNI loader for FastJava libraries
MIT License — See LICENSE for details.
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. 🚀📋
