ZiggyAlloc 1.2.3

dotnet add package ZiggyAlloc --version 1.2.3
                    
NuGet\Install-Package ZiggyAlloc -Version 1.2.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ZiggyAlloc" Version="1.2.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ZiggyAlloc" Version="1.2.3" />
                    
Directory.Packages.props
<PackageReference Include="ZiggyAlloc" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ZiggyAlloc --version 1.2.3
                    
#r "nuget: ZiggyAlloc, 1.2.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ZiggyAlloc@1.2.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ZiggyAlloc&version=1.2.3
                    
Install as a Cake Addin
#tool nuget:?package=ZiggyAlloc&version=1.2.3
                    
Install as a Cake Tool

ZiggyAlloc

High-performance unmanaged memory management for .NET with explicit control and zero GC pressure.

NuGet Build Status License

Overview

ZiggyAlloc is a high-performance C# library for unmanaged memory management. It provides explicit control over memory allocation while maintaining safety through well-designed abstractions and automatic cleanup mechanisms.

Key Features

  • High-Performance Memory Management: Direct access to native memory allocation
  • Multiple Allocator Strategies: System, scoped, debug, pool, and hybrid allocators
  • Type-Safe Memory Access: UnmanagedBuffer<T> with bounds checking
  • Memory Safety: Leak detection, bounds checking, and automatic cleanup
  • RAII Support: Automatic cleanup using using statements
  • Span<T> Integration: Zero-cost conversion to high-performance spans
  • Native Interop: Direct pointer access for native API calls

Quick Start

using ZiggyAlloc;

// Create allocator
var allocator = new SystemMemoryAllocator();

// Allocate memory with automatic cleanup
using var buffer = allocator.Allocate<int>(1000);

// Use like a normal array with bounds checking
buffer[0] = 42;
int value = buffer[0];

// Convert to Span<T> for high-performance operations
Span<int> span = buffer;
span.Fill(123);

Allocators

ZiggyAlloc provides multiple allocator implementations for different scenarios:

SystemMemoryAllocator

Direct system memory allocation with tracking.

ScopedMemoryAllocator

Arena-style allocator that frees all memory when disposed.

DebugMemoryAllocator

Tracks allocations and detects memory leaks with caller information.

UnmanagedMemoryPool

Reduces allocation overhead by reusing previously allocated buffers.

HybridAllocator

Automatically chooses between managed and unmanaged allocation based on size and type for optimal performance.

Performance

Benchmarks show significant performance improvements over managed arrays for large data:

  • Large Data Types: 40%+ performance improvement with unmanaged arrays
  • GC Pressure: Eliminated completely with unmanaged allocations
  • Memory Pooling: Reduces allocation overhead by reusing buffers
  • Hybrid Allocation: Uses managed arrays for small allocations (faster) and unmanaged memory for large allocations (no GC pressure)

See benchmark results in the benchmarks directory for detailed performance comparisons.

Examples

The examples directory contains organized examples demonstrating various use cases:

Basic Usage

  • Simple memory allocation and automatic cleanup
  • Using using statements for RAII-style memory management

Advanced Features

  • Different allocator types and their use cases
  • Memory leak detection
  • High-performance buffer operations
  • Native interop scenarios

Performance Optimization

  • Memory pooling for frequent allocations
  • Hybrid allocation strategies
  • Avoiding GC pressure with large allocations

Real-World Applications

  • Image processing without GC pressure
  • Scientific computing with large datasets
  • Native API interop

To run examples:

cd examples
dotnet run -- basic
dotnet run -- allocators
dotnet run -- performance
dotnet run -- realworld

Installation

Install the NuGet package:

dotnet add package ZiggyAlloc

Or add to your .csproj:

<PackageReference Include="ZiggyAlloc" Version="1.2.1" />

Documentation

Requirements

  • .NET 8.0 or later
  • unsafe code enabled (configured in package)

License

This project is licensed under the MIT License - see the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.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
1.2.3 154 8/29/2025
1.2.1 159 8/29/2025
1.2.0 161 8/29/2025
1.0.2 117 7/29/2025
1.0.1 111 7/29/2025
1.0.0 116 7/28/2025

See CHANGELOG.md for detailed release notes.