This project demonstrates Java systems programming capabilities using GraalVM Native Image with unmanaged memory operations and the Epsilon no-op garbage collector.
- Unmanaged Memory Operations: malloc, calloc, realloc, and free
- Epsilon GC: No-op garbage collector for minimal GC overhead
- Native Image: Compiled to native executable with GraalVM
- GraalVM 25+ with Native Image
- Maven 3.6+
- Java 21+
mvn clean package
./build-native.bat
./com.example.systemsprogrammingdemo.exe
The application demonstrates:
- malloc() - Allocate uninitialized memory
- calloc() - Allocate zero-initialized memory
- realloc() - Resize allocated memory
- Memory Operations - Pointer arithmetic and addressing
- Large Allocations - Performance testing with 1MB allocations
The --gc=epsilon
flag enables the Epsilon garbage collector:
- No-op GC that doesn't actually collect garbage
- Minimal overhead for applications that manage their own memory
- Perfect for systems programming with manual memory management
- Application terminates when heap is exhausted
// Allocate uninitialized memory
CIntPointer ptr = UnmanagedMemory.malloc(size);
// Allocate zero-initialized memory
CLongPointer ptr = UnmanagedMemory.calloc(size);
// Resize allocated memory
ptr = UnmanagedMemory.realloc(ptr, newSize);
// Free memory
UnmanagedMemory.free(ptr);
- Unmanaged memory is not managed by the garbage collector
- Always free unmanaged memory to avoid leaks
- Epsilon GC is ideal for short-lived applications or those with manual memory management
- Native Image provides fast startup and low memory footprint