Giter Site home page Giter Site logo

xoofx / varena Goto Github PK

View Code? Open in Web Editor NEW
155.0 2.0 5.0 85 KB

Varena is a .NET library that provides a fast and lightweight arena allocator using virtual memory.

License: BSD 2-Clause "Simplified" License

C# 100.00%
allocator arena-allocator dotnet virtual-memory

varena's Introduction

Varena ci Coverage Status NuGet

Varena is a .NET library that provides a fast and lightweight arena allocator using virtual memory.

Features

  • Create very large continuous byte buffers and arrays (e.g 1 TiB) of data without committing the virtual memory to the physical memory.
    • Only use the memory that is allocated, not the total capacity reserved!
  • Fast bump allocator with a commit per block (default is 64 KiB of memory committed)
  • Use VirtualBuffer for manipulating bytes.
  • Use VirtualArray<T> for manipulating a dynamic array of unmanaged data.
  • Compatible with .NET6.0+ and on all platforms (Windows, Linux, macOS)

Usage

using Varena;

// The manager keeps track of all created arenas (buffers, arrays)
using var manager = new VirtualArenaManager();

// Create a byte buffer and reserve 1 GiB of continuous memory (but not yet allocated)
var arena1 = manager.CreateBuffer("Arena1", 1 << 30);
// Allocate 1024 bytes -> The arena commits a block 64 KiB of memory (configurable)
var span = arena1.AllocateRange(1024);
span[0] = 1;
// Allocate 2048 bytes -> The arena keeps allocating in the previous commit block of 64 KiB
var span2 = arena1.AllocateRange(2048);
span2[0] = 1;

// Create a data array and reserve 1 MiB of continuous memory (but not yet allocated)
var arena2 = manager.CreateArray<Guid>("Arena2", 1 << 20);
// Allocate sizeof(Guid) * 1024 bytes -> The arena commits a block 64 KiB of memory (configurable)
var span3 = arena2.AllocateRange(1024);
span3[0] = Guid.NewGuid();

Documentation

You will find more details about how to use Varena in this user guide.

License

This software is released under the BSD-Clause 2 license.

Author

Alexandre Mutel aka xoofx.

varena's People

Contributors

xoofx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.