NativeMemory 0.0.1
dotnet add package NativeMemory --version 0.0.1
NuGet\Install-Package NativeMemory -Version 0.0.1
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="NativeMemory" Version="0.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NativeMemory --version 0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NativeMemory, 0.0.1"
#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 NativeMemory as a Cake Addin #addin nuget:?package=NativeMemory&version=0.0.1 // Install NativeMemory as a Cake Tool #tool nuget:?package=NativeMemory&version=0.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
NativeMemory
Important bits and pieces
NativeArray<T>
: Access native dataNativeArrayPool<T>
: Just likeArrayPool
, pools native arraysINativeAllocator
HGlobalMemAllocator
: Allocates memory using Marshal.AllocHGlobalCoTaskMemAllocator
: Marshal.AllocCoTaskMem
Sample Code
Using the ArrayPool:
// allocates a new array with 10 bytes
var array = new NativeArray<byte>(10);
array.Dispose();
// Borrow an array of 200 bytes
array = NativeArrayPool<byte>.SharedHGlobal.Rent(200);
// Return the array to the pool.
NativeArrayPool<byte>.SharedHGlobal.Return(array);
// Borrow an array of 200 bytes and return it using the dispose pattern.
using (array = NativeArrayPool<byte>.SharedHGlobal.Rent(200))
{
}
Thanks
Special thanks to the guys from Poltergeist, where i mostly stole this code got my inspiration from.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.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.0.1 | 226 | 11/28/2022 |