Hezium.Memory provides nint-indexed BigArray, BigMemory, BigSpan and related types for .NET 10+, enabling arrays and spans larger than Array.MaxLength with a familiar API.

Stars

37

7-day growth

No data

Forks

2

Open issues

1

License

MIT

Last updated

2026-07-28

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It bridges a gap in .NET's memory model by supporting managed arrays beyond the 2^31-1 element limit while preserving the Array/Memory/Span programming patterns, with GC support and benchmarks showing competitive or superior performance compared to jagged arrays.

Who it is for

  • .NET developers working with extremely large datasets
  • High-performance computing and simulation engineers
  • Game developers needing large contiguous buffers
  • Data pipeline and columnar storage implementors

Use cases

  • Storing and processing columnar data exceeding System.Array.MaxLength
  • Precomputed lookup tables for large-scale simulations
  • Native interop buffers that require managed memory with GC support
  • File-backed processing pipelines with very large one-dimensional collections

Strengths

  • Familiar API surface mirroring Array, Span<T>, Memory<T> with nint lengths and indexes
  • GC-friendly managed allocation with optional pinned support
  • Benchmark results show comparable or better allocation and access performance versus jagged arrays
  • Provides search, sort, copy, trim, and split operations consistent with System.Span<T>

Considerations

  • Requires .NET 10 or later
  • Value types larger than 65535 bytes are rejected
  • Large arrays use chunked storage which may introduce slight overhead for certain operations

README quick start

Hezium.Memory

BigArray, BigMemory, BigReadOnlyMemory, BigSpan, and BigReadOnlySpan for .NET code that wants the Array/Memory/Span programming model with nint lengths and indexes.

The standard T[] and Span APIs are excellent until the array you want to model is larger than the largest single managed array. Hezium.Memory keeps the surface area familiar: allocate an owner, take a span-like view, slice it, search it, copy it, sort it, and pass references around without inventing a second indexing style.

dotnet add package Hezium.Memory
using Hezium.Memory;

nint length = 10_000_000_000;
BigArray buffer = new(length);

buffer[0] = 1;
buffer[5_000_000_000] = 2;
buffer[length - 1] = 3;

BigSpan window = buffer.AsBigSpan(5_000_000_000, 1024);

window[0] = 42;
Console.WriteLine(buffer[5_000_000_000]); // 42

BigArray allocates on managed memory with GC support, so you can use it with reference types and it will be collected when no longer being used.

For explicit GC-style allocation, use GC.AllocateBigArray() or GC.AllocateUninitializedBigArray(). Both APIs accept the same pinned option as the built-in GC array allocation helpers.

BigArray zeroed = GC.AllocateBigArray(length);
BigArray scratch = GC.AllocateUninitializedBigArray(length);
BigArray pinned = GC.AllocateBigArray(length, pinned: true);

For more details about how this library was built, see the Introduction.

Why

Some workloads are naturally one-dimensional and very large: columnar data, precomputed lookup tables, native interop buffers, generated datasets, simulation state, and file-backed processing pipelines. The important part is not only "can I allocate a lot of elements", but "can I keep using the same mental model when I do?"

Hezium.Memory is built around that goal:

  • BigArray is the owning storage type.
  • BigMemory is the mutable storable view.
  • BigReadOnlyMemory is the read-only storable view.
  • BigSpan is the mutable stack-only view.
  • BigReadOnlySpan is the read-only stack-only view.
  • Lengths, indexes, and offsets are nint.
  • APIs intentionally resemble Array, Memory, ReadOnlyMemory, Span, ReadOnlySpan, and MemoryMarshal.

BigArray

BigArray is a one-d

Description

A one-dimensional, zero-based BigArray, BigSpan and BigReadOnlySpan types and helpers for arrays that exceed the standard .NET array limits.

Related repositories

Similar projects matched by category, topics, and programming language.

loyal-studio
loyal-studio GitHub avatar

Honami-Animation-System

Honami is a visual, UI-first animation system for Unity 6 that replaces Mecanim with timeline editors, node graphs, and a zero-allocation runtime, letting animators author animations with almost no code.

C#
239
aakk007
aakk007 GitHub avatar

RogueCleaner

A Windows tool that detects and removes malicious leftovers from right-click menus, startup items, services, scheduled tasks, browser extensions, and file associations.

C#
212
ThioJoe
ThioJoe GitHub avatar

Thio-Background-App-Notifier

A lightweight Windows tool that notifies you about new auto-starting background services and scheduled tasks that Windows normally doesn't alert you about.

C#
147