UnmanagedArray 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package UnmanagedArray --version 1.0.2                
NuGet\Install-Package UnmanagedArray -Version 1.0.2                
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="UnmanagedArray" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add UnmanagedArray --version 1.0.2                
#r "nuget: UnmanagedArray, 1.0.2"                
#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.
// Install UnmanagedArray as a Cake Addin
#addin nuget:?package=UnmanagedArray&version=1.0.2

// Install UnmanagedArray as a Cake Tool
#tool nuget:?package=UnmanagedArray&version=1.0.2                

Unmanaged Array

GitHub license nuget

An Effective tool for unmanaged array in C#.

About

Array in C# is allocated in managed memory.

UnmanagedArray<T> in this library is allocated in unmanaged memory.

In other words, items in UnmanagedArray<T> is not collected by Garbage Collection.

Supported Types

The only type of item UnmanagedArray<T> supports is unmanaged type.

unmanaged type is int, float, recursive-unmanaged struct, and so on.

string, and other types which are class are NOT SUPPORTED.

(because reference types are allocated in managed memory on C#.)

Requirements and Dependencies (On Building)

  • .NET Standard 2.0
  • C# 8.0

Building from Source

$ git clone https://github.com/ikorin24/UnmanagedArray.git
$ cd UnmanagedArray
$ dotnet build src/UnmanagedArray/UnmanagedArray.csproj -c Release

# ----> src/UnmanagedArray/bin/Release/netstandard2.0/UnmanagedArray.dll

Installation

Install from Nuget by package manager console (in Visual Studio).

https://www.nuget.org/packages/UnmanagedArray

PM> Install-Package UnmanagedArray

How to Use

The way of use is similar to normal array.

Unmanaged resources are release when an instance goes through the scope.

// UnmanagedArray releases its memories when it goes through the scope.
using(var array = new UnmanagedArray<int>(10))
{
    for(int i = 0;i < array.Length;i++)
    {
        array[i] = i;
    }
}

If not use the using scope, you can release the memories by Dispose() method.

var array = new UnmanagedArray<int>(10);
array[3] = 100;
array.Dispose();       // The memories allocated in unmanaged is released here.

Of cource, LINQ is supported.

using(var array = Enumerable.Range(0, 10).ToUnmanagedArray())
using(var array2 = array.Where(x => x >= 5).ToUnmanagedArray()) {
    for(int i = 0; i < array2.Length; i++) {
        Console.WriteLine(array2[i]);       // 5, 6, 7, 8, 9
    }
}

NOTICE

UnmanagedArray<T> has Finalizer and releases its unmanaged resources automatically when you forget releasing that.

However, you have to release them explicitly ( by using scope or Dispose() ).

License and Credits

This is under MIT license.

This software includes the work that is distributed in the Apache License 2.0.

Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0)

Author

github: ikorin24

Release Note

2020/01/11 v1.0.0

nuget

  • First release

2020/01/12 v1.0.1

nuget

  • Performance improvement of iteration by foreach, that is as faster as T[] (normal array).

2020/01/15 v1.0.2

nuget

  • Great performance improvement of accessing to the item by index. (array[i])
Product 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on UnmanagedArray:

Package Downloads
Akihabara

Mediapipe wrapper library.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on UnmanagedArray:

Repository Stars
lolo77777/OpenCVVision
使用OpenCvSharp创建常用功能集合
Version Downloads Last updated
2.1.3 3,525 2/10/2021
2.1.2 370 1/5/2021
2.1.1 435 11/26/2020
2.1.0 537 10/5/2020
2.1.0-rc 334 7/27/2020
2.0.1 451 6/6/2020
2.0.0 470 4/30/2020
1.0.3 494 4/30/2020
1.0.2 556 1/15/2020
1.0.1 479 1/11/2020
1.0.0 522 1/11/2020