DenevCloud.Core.Unmanaged
1.0.1-preview1
This is a prerelease version of DenevCloud.Core.Unmanaged.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DenevCloud.Core.Unmanaged --version 1.0.1-preview1
NuGet\Install-Package DenevCloud.Core.Unmanaged -Version 1.0.1-preview1
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="DenevCloud.Core.Unmanaged" Version="1.0.1-preview1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DenevCloud.Core.Unmanaged --version 1.0.1-preview1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DenevCloud.Core.Unmanaged, 1.0.1-preview1"
#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 DenevCloud.Core.Unmanaged as a Cake Addin #addin nuget:?package=DenevCloud.Core.Unmanaged&version=1.0.1-preview1&prerelease // Install DenevCloud.Core.Unmanaged as a Cake Tool #tool nuget:?package=DenevCloud.Core.Unmanaged&version=1.0.1-preview1&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Unmanaged Objects in C# made easy
DenevCloud.Core.Unmanaged API allows for allocating unmanaged objects on the heap and deallocate them then they get out of scope. UnmanagedObject<T>
implements the IDisposable
interface and follows this pattern.
Examples
//Example 1
var unmanaged = new UnmanagedObject<MyStruct>(); // Creates default(MyStruct)
unmanaged.Value = new MyStruct() { Age = 99 };
ref var myStruct = ref unmanaged.RefValue;
unmanaged. Dispose(); //never forger to dispose if it's not under 'using' scope
//Example 2
using var unmanaged = new UnmanagedObject<MyStruct>();
T* handle = unmanaged.GetHandle();
*handle = new MyStruct() { Age = 99 }; //The value within unmanaged also changes since it's pointer
//Example 3
using var unmanaged = new UnmanagedObject<MyStruct>();
var myStruct2 = new MyStruct();
unmanaged.Update(&myStruct2);
Since Version 1.0.1
New feature has been added called AllocationManager
which allows to reuse the blocks of memory that are allocated. This greatly improves performance since no new memory blocks allocations are made.
Settings
using DenevCloud.Core.Unmanaged;
Settings.UseAllocationManager = true; //Default is false
Settings.MaxAllocations = 32; //Default is 16, corresponds to total number of memory blocks allocated
Settings.MaxAllocationLifetime = TimeSpan.FromMinutes(2); //Default is 2 minutes, corresponds to the max lifetime of a memory block (if object disposed)
Settings.ExpiredCheck = TimeSpan.FromSeconds(5); //Default is 5 seconds, corresponds to how ofter the AllocationManager checks for expired memory blocks
Benchmarks
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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.
-
net8.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.0.2-preview1 | 99 | 1/19/2024 |
1.0.1-preview1 | 80 | 1/17/2024 |
1.0.0-preview1 | 71 | 1/16/2024 |