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
NativeMemoryCleaner- Automatic cleanup using Cleaner APIResourceTracker- Tracks allocations for leak detectionTrackedArena- Arena wrapper with tracking
Memory Safety Strategy
The transport uses several mechanisms to ensure memory safety:
- Reference counting: BufferRef uses atomic refcount to track usage
- Cleaner registration: Phantom reference cleanup for GC-triggered release
- Resource tracking: Debug mode tracks all allocations with stack traces
- 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:
-
ClassesClassDescriptionProvides automatic native memory cleanup using the Cleaner API.Cleanable wrapper that properly tracks explicit cleanup.Tracks native memory allocations for debugging and leak detection.Record of a tracked allocation.Arena wrapper that integrates with ResourceTracker and NativeMemoryCleaner.