ZeroAlloc.Memory
0.1.0
dotnet add package ZeroAlloc.Memory --version 0.1.0
NuGet\Install-Package ZeroAlloc.Memory -Version 0.1.0
<PackageReference Include="ZeroAlloc.Memory" Version="0.1.0" />
<PackageVersion Include="ZeroAlloc.Memory" Version="0.1.0" />
<PackageReference Include="ZeroAlloc.Memory" />
paket add ZeroAlloc.Memory --version 0.1.0
#r "nuget: ZeroAlloc.Memory, 0.1.0"
#:package ZeroAlloc.Memory@0.1.0
#addin nuget:?package=ZeroAlloc.Memory&version=0.1.0
#tool nuget:?package=ZeroAlloc.Memory&version=0.1.0
ZeroAlloc.Memory
Zero-allocation unmanaged memory allocators, linear arenas, virtual-memory mirrored ring buffers, and native collections for .NET 10 and netstandard2.1 (Unity / client / server).
Compiled as AnyCPU and tested in CI across 64-bit x64 and ARM64 (linux-x64, linux-arm64, win-x64, osx-arm64).
Origin & Intent
ZeroAlloc.Memory was originally built as the memory and IPC foundation for a high-tickrate distributed game/simulation engine (Echoes of Bathala) where:
- Gen0/Gen2 GC pauses in hot simulation and networking loops were unacceptable,
- Variable-length ring buffers needed contiguous
Span<byte>reads/writes across wrap-around boundaries without split copies, and - A single memory foundation had to run identically across .NET 10 Linux servers (x64/ARM64) and netstandard2.1 Unity clients.
Installation
dotnet add package ZeroAlloc.Memory
When to Use (and When NOT to Use)
Use ZeroAlloc.Memory When… |
Do NOT Use When… |
|---|---|
Standard ArrayPool<T>, Dictionary<K,V>, or Channel<T> causes measurable GC pauses in hot loops. |
Standard .NET BCL collections already meet your latency budget. |
You store unmanaged structs or raw byte frames with deterministic tick/frame lifetimes. |
You need to store managed reference types (class, string). |
You have strictly 1P/1C (SpscRing, MirroredSpscRing) or NP/1C (BoundedMpscRing, MirroredMpscRing) thread topologies. |
You have multiple concurrent consumers (MPMC is intentionally excluded). |
See the full Collections & Arenas Decision Guide and Architecture & Memory Model.
Safety Contract & Known Limitations
- 64-Bit Process Required: Built as
AnyCPUforx64andARM64portability; 32-bit processes (x86/arm32) are unsupported and throwPlatformNotSupportedExceptioninPageAllocator. - Manual Lifetime (
IDisposable): Value-type native handles and wrappers do not rely on GC finalizers for hot-path cleanup. Failing to callDispose()leaks unmanaged/virtual memory. - Thread-Topology Guarantees:
SpscRingandMirroredSpscRingare strictly Single-Producer / Single-Consumer. CallingTryEnqueue/TryWritefrom multiple threads requiresBoundedMpscRingorMirroredMpscRing. - Debug vs. Release Guards:
UnmanagedPage/DebugMemoryGuardtrailing canaries (0xDEADBEEF) catch buffer overruns inDebugbuilds and compile out to zero overhead inRelease.
Quick Start
using Memory.Arena;
using Memory.Collections.Spsc;
// 1. Frame/tick-scoped linear arena (0 GC allocations)
using var arena = new UnmanagedLinearArena(capacityBytes: 64 * 1024);
int* buffer = arena.Allocate<int>(128);
buffer[0] = 42;
// 2. Cache-padded SPSC ring buffer (strictly 1 producer, 1 consumer)
using var ring = new SpscRing<long>(capacity: 1024);
ring.TryEnqueue(123456L);
ring.TryDequeue(out long value);
Benchmarks (.NET 10 X64, 0 B Managed Allocation)
FlatMap/NativeFlatMapvsDictionary<K,V>(10,000keys):276 µsvs759 µson hits (2.75× faster),175 µsvs855 µson in-place mutation (4.88× faster),0 Ballocated. (Note: dense full-table iteration remains faster inDictionary— see full tradeoffs.)UnmanagedLinearArena(10,000batch slices):4,101 ns(0.41 ns/item,0 Ballocated).SpscRing(64Bzero-copy round-trip):269.8 ns,0 Ballocated.
Full BenchmarkDotNet tables & reproduction commands: docs/benchmarks/README.md
Building, Testing & Benchmarking
# Run full unit & concurrency stress suite (223 tests)
dotnet test -c Release
# Verify netstandard2.1 compatibility
dotnet build src/Memory/Memory.csproj -c Release -f netstandard2.1
# Run BenchmarkDotNet suite
dotnet run --project benchmark/Memory.Benchmark -c Release -- --filter *
License
MIT © 2026 Markism-JA
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- No dependencies.
-
net10.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 0 | 11/24/2026 |