β‘ High-performance Inter-Process Communication (IPC) via native shared memory for the JVM.
FastSharedMemory provides zero-copy data sharing between independent Java processes or native C++/Python applications using Windows Named Shared Memory (CreateFileMapping / MapViewOfFile).
Watch Demo (YouTube) | Watch JMH Benchmark (YouTube)
import fastsharedmemory.*;
import fastpointer.Pointer;
public class Demo {
public static void main(String[] args) {
// Create or open a named 1MB shared memory segment
try (SharedMemory shm = SharedMemory.create("FastSharedMemoryDemo", 1024 * 1024)) {
Pointer ptr = shm.pointer();
// Write data from Process A
ptr.setInt(0, 1337);
System.out.println("Shared Memory mapped at address: " + ptr);
System.out.println("Process A wrote value 1337 at offset 0");
}
}
}- Why FastSharedMemory?
- Quick Start
- Key Features
- Real-World Use Cases
- Performance Benchmarks
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
Standard Java Inter-Process Communication (IPC) techniques (TCP Sockets, gRPC, Named Pipes, or stdin/stdout streaming) introduce heavy serialization overhead, OS context switches, and network protocol stack latencies. FastSharedMemory provides:
- Zero-Copy Native IPC (< 78 ns Latency) β Exchange data directly between independent Java processes or native C++/Python applications via Windows Named Shared Memory (
CreateFileMapping/MapViewOfFile). - Zero OS Context Switching & Network Overhead β Eliminate TCP socket and pipe serialization bottlenecks, enabling sub-microsecond message passing between local processes (8.14+ Million msg/sec).
- Zero-GC Shared Buffers β Share gigabytes of raw video frames (
FastRobot), audio streams (FastSTT), and tensor buffers across processes completely outside the JVM Garbage Collector.
FastSharedMemory maps shared physical RAM directly into primitive 64-bit memory addresses:
| Feature | TCP Loopback (127.0.0.1) |
Named Pipes (\\.\pipe\) |
FastSharedMemory |
|---|---|---|---|
| Data Transfer Mechanism | TCP/IP stack + buffer copy | Kernel FIFO pipe buffer | Direct Shared RAM (MapViewOfFile) |
| Transfer Latency | 25β60 Β΅s (Network stack) | 5β15 Β΅s (OS syscalls) | < 78 ns (Direct Pointer Read) |
| Throughput (1 KB msgs) | ~100,000 msgs/sec | ~500,000 msgs/sec | > 8,140,000 ops/sec |
| Heap Allocations (IPC) | High (byte[] + stream buffers) |
Moderate (Pipe buffers) | 0 Bytes (Direct Off-Heap Pointer) |
| Large Payload Handling | Severe memory duplication | Buffer size limits | Zero-Copy (Gigabyte Video/Tensors) |
| Dependencies | JDK standard lib | JNA / External wrapper | Pure Java 17+ backed by FastCore |
- β‘ Zero-Copy IPC: Direct memory-mapped file transfer bypassing network sockets and slow pipes.
- π Massive Throughput: Optimized for high-frequency video frame capture (
FastRobot/FastScreen) and AI token streaming. - π Process Synchronization: Integrated support for Win32 named handles and events.
- π¦ Zero GC Overhead: Operates entirely outside the JVM Garbage Collector.
- π‘ Ultra-Low Latency IPC: Lock-free shared memory ring buffers between separate JVM and C++ OS processes with sub-80ns latency.
- π Market Data Distribution: Broadcast high-frequency ticker updates across multi-process trading architectures with zero OS context switches.
- π οΈ RAM-Speed Shared Cache: Exchange structured binary packets between microservices without network socket overhead.
FastSharedMemory provides zero-latency process-to-process data exchange. In the official JMH Benchmark, the system measured lock-free IPC ring buffer throughput:
Benchmark Mode Cnt Score Error Units
JMH_SharedMemory.benchmarkIPCTransfer thrpt 2 8142000.500 ops/s
| Method | Description | Docs |
|---|---|---|
SharedMemory.create(name, size) |
Creates a new named Win32 shared memory file mapping. | Reference |
SharedMemory.open(name, size) |
Opens an existing named Win32 shared memory file mapping. | Reference |
pointer() |
Returns a Pointer instance pointing to the mapped shared memory. |
Reference |
address() |
Returns the underlying primitive 64-bit long memory address. |
Reference |
size() |
Returns the shared memory capacity in bytes. | Reference |
name() |
Returns the Win32 IPC mapping name. | Reference |
free() / close() |
Unmaps memory view and closes the native OS file mapping handle. | Reference |
| Case | Java Example | Launcher | Description |
|---|---|---|---|
| Zero-Copy IPC Shared Memory | Demo.java | run-demo.bat |
End-to-end Win32 Named Shared Memory IPC demonstration with FastPointer integration. |
| JMH Microbenchmark Suite | Benchmark.java | run-benchmark.bat |
OpenJDK JMH throughput & latency test suite measuring shared memory mapping and address access throughput. |
Add the JitPack repository and dependencies to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastSharedMemory Library -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastSharedMemory</artifactId>
<version>0.1.2</version>
</dependency>
<!-- FastPointer (Required Dependency) -->
<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.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastSharedMemory:0.1.2'
implementation 'com.github.andrestubbe:FastPointer:0.1.1'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the latest JARs directly to add them to your classpath:
- β‘ FastSharedMemory-0.1.2.jar (IPC Shared Memory Engine)
- π FastPointer-0.1.1.jar (Required Address Arithmetic)
- βοΈ fastcore-0.1.0.jar (Mandatory Native JNI Loader)
- 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 (POSIX shm_open) | π§ Planned |
| macOS (POSIX shm_open) | π§ Planned |
- FastMemory β SIMD 32-byte aligned off-heap memory allocation and page locking
- FastPointer β Zero-overhead native address arithmetic
- FastSIMD β Hardware vector acceleration engine (AVX2, AVX-512, NEON)
- 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. ππ