cohtml.Net.IVirtualAllocator

Virtual memory allocator interface used by Cohtml for scripting memory allocations.

Inherits from SystemIDisposable

Public Functions

Name
virtual voidDispose()
virtual ulongGetAllocationPageSize()
virtual ulongGetCommitPageSize()
virtual global.System.IntPtrAllocate(global.System.IntPtr address, ulong size, ulong alignment, int protection, int flags)
Reserve and/or commit a memory region.
virtual boolFree(global.System.IntPtr address, ulong size, int flags)
Releases or decommits a memory region.
virtual boolPartialFree(global.System.IntPtr address, ulong oldSize, ulong newSize, int flags)
Releases or decommits part of a memory region.

Protected Attributes

Name
boolswigCMemOwn

Public Functions Documentation

function Dispose

virtual void Dispose()

function GetAllocationPageSize

virtual ulong GetAllocationPageSize()

function GetCommitPageSize

virtual ulong GetCommitPageSize()

function Allocate

virtual global.System.IntPtr Allocate(
    global.System.IntPtr address,
    ulong size,
    ulong alignment,
    int protection,
    int flags
)

Reserve and/or commit a memory region.

Parameters:

  • address a hint when reserving memory and a concrete address when committing.
  • size the number of bytes to allocate.
  • alignment the required alignment for the return address.
  • protection specifies a protection type for the memory region.
  • flags type of the allocation (commit, reserve or reserve & commit).

Return: address of the allocated memory region.

function Free

virtual bool Free(
    global.System.IntPtr address,
    ulong size,
    int flags
)

Releases or decommits a memory region.

Parameters:

  • address a concrete address to release or decommit.
  • size the number of bytes to deallocate.
  • flags type of the deallocation (decommit or release).

Return: true if the function succeeds, otherwise false.

Note: A release call is expected to also decommit the memory.

function PartialFree

virtual bool PartialFree(
    global.System.IntPtr address,
    ulong oldSize,
    ulong newSize,
    int flags
)

Releases or decommits part of a memory region.

Parameters:

  • address a address of the start of the region.
  • oldSize the original size of the region
  • newSize the new size of the region
  • flags type of the deallocation (decommit or release).

Return: true if the function succeeds, otherwise false.

Note: Some platforms (like Microsoft Windows) may not support partial release of reserved regions. On these platforms, only decommit this memory and wait for a final release. However, the final release will use newSize as size of the memory to be released. At least on Microsoft Windows this is ok, since it releases the whole memory region, ignoring the size.

Protected Attributes Documentation

variable swigCMemOwn

bool swigCMemOwn;