Package express.mvp.myra.transport.memory


package express.mvp.myra.transport.memory
Native memory management utilities for the transport layer.

This package provides components for safe management of native (off-heap) memory, ensuring resources are properly released even in exceptional circumstances.

Key Components

Memory Safety Strategy

The transport uses several mechanisms to ensure memory safety:

  1. Reference counting: BufferRef uses atomic refcount to track usage
  2. Cleaner registration: Phantom reference cleanup for GC-triggered release
  3. Resource tracking: Debug mode tracks all allocations with stack traces
  4. Arena lifecycle: Shared arenas with explicit scope management

Best Practices

  • Always use try-with-resources for deterministic cleanup
  • Enable resource tracking during development to detect leaks
  • Register cleaners as a safety net, not primary cleanup mechanism
See Also: