Class MemAlloc
Provides functions to embedd a memory usage limit in .net applications. Amount of available memory is calculated using this indicators:
- Application architecture (x86, x64). TryAlloc and Alloc will be ignored on x64 by default
- Current application memory usage
- Free system memory, minus a minimum of free memory which must be left for the system to run and catch memory peaks
Inheritance
Inherited Members
Namespace: Simplic.Memory
Assembly: Simplic.CoreLib.dll
Syntax
public static class MemAlloc
Properties
| Improve this Doc View SourceIsInUse
If set to false, memory allocation will always work
Declaration
public static bool IsInUse { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
MainProcess
Main process of the current application
Declaration
public static Process MainProcess { get; set; }
Property Value
Type | Description |
---|---|
System.Diagnostics.Process |
MaxMemoryAllocation
Maximum memory the application is allowed to allocate for private memory usage
Declaration
public static ulong MaxMemoryAllocation { get; set; }
Property Value
Type | Description |
---|---|
System.UInt64 |
MinFreeSystemMemory
Minimum of system memory which should be free
Declaration
public static ulong MinFreeSystemMemory { get; set; }
Property Value
Type | Description |
---|---|
System.UInt64 |
X86Only
If set to true (default) the monitoring will only work for x86 processes
Declaration
public static bool X86Only { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
| Improve this Doc View SourceAddUnmanagedUsedMemory(Int64)
Add memory which will be used in an unmanaged library
Declaration
public static void AddUnmanagedUsedMemory(long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | Amount of unmanaged memory |
Alloc()
Throws an exception, if more memory is allocated than the maximum allowed
Declaration
public static void Alloc()
Alloc(UInt64)
Throws an exception, if more memory is allocated than the maximum allowed
Declaration
public static void Alloc(ulong bytes)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | bytes | Bytes which should be allocated |
FinalizeCollectedData()
Collect and wait for finalizing data
Declaration
public static void FinalizeCollectedData()
RemoveUnmanagedUsedMemory(Int64)
Remove memory which will be used in an unmanaged library
Declaration
public static void RemoveUnmanagedUsedMemory(long bytes)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | bytes | Amount of unmanaged memory |
TryAlloc()
Return true if no more memory is allocated than the maximum allowed
Declaration
public static bool TryAlloc()
Returns
Type | Description |
---|---|
System.Boolean | Return true if no more memory is allocated than the maximum allowed |
TryAlloc(UInt64)
Return true if no more memory is allocated than the maximum allowed
Declaration
public static bool TryAlloc(ulong bytes)
Parameters
Type | Name | Description |
---|---|---|
System.UInt64 | bytes | Bytes which should be allocated |
Returns
Type | Description |
---|---|
System.Boolean | Return true if no more memory is allocated than the maximum allowed |