View Binding

The view binding system is the core innovation enabling zero-allocation memory access. Instead of creating new objects for each memory view, references are shared.

MemoryView

A lightweight data container holding positioning information:

public class MemoryView {
    MemorySegment segment;  // The underlying memory segment
    long start;             // Starting offset within segment
    long length;            // Length of data in bytes  
    Memory source;          // Optional reference for lifecycle
}

Design principles:

  • Just 4 fields - minimal overhead

  • Mutable fields for reuse

  • No ownership - views don't own memory

  • Pre-allocated once, reused via binding

BoundView

The binding implementation that enables zero-allocation views:

The Two Binding Paths

Path 1: Direct Binding (offset=0)

When binding to the entire memory region, share the source's view directly:

Memory layout:

Path 2: Mapped Binding (offset > 0)

When binding with offset, use the pre-allocated mappedView:

Memory layout:

View Propagation

The key insight: views share references. When underlying memory changes, all views see it immediately.

Propagation diagram:

Comparison to Standard Java

Aspect
Our Design
Java Standard

Slice creation

Pre-allocated mappedView

segment.asSlice() allocates

View sharing

Direct reference when possible

Always creates new object

JIT dependency

Works without JIT

Relies on escape analysis

Allocation

Zero

Object per slice

Predictable

Yes - fixed cost

Varies with JIT warmup

Protocol Header Binding

Headers extend BoundView to inherit zero-allocation binding:

Performance Summary

Operation
Assignments
Allocations

Direct bind

2

0

Mapped bind

5

0

Unbind

1-4

0

View propagation

0

0

The entire binding system operates with zero allocations in hot paths.

Last updated