Memory Package

The Memory Package provides high-performance, zero-allocation memory management for network packet processing at 100M+ packets per second.

Why This Exists

Java's standard memory management creates garbage collection pressure that causes latency spikes in high-throughput scenarios. The Memory Package solves this with:

  • Pre-allocated object pools

  • View-based binding (no slice allocations)

  • Slab memory allocation with automatic cleanup

  • Lock-free concurrent access

Key Concepts

Memory Types

Two memory types for different scenarios:

Type
Segment
Use Case

FixedMemory

Permanently bound

Pool-allocated buffers

ScopedMemory

Rebindable

Zero-copy native capture

View Binding

Instead of creating slice objects, views share references:

Pool Infrastructure

Three pool types for different needs:

Pool
Purpose

FreeListPool

Generic objects, lock-free CAS

BucketPool

Variable-sized allocations

MemoryPool

FixedMemory with slab backing

Quick Example

Performance

Operation
Cost
Allocations

Direct bind

2 assignments

0

Pool allocate

CAS operation

0

Pool recycle

CAS operation

0

Next Steps

Last updated