Skip to content
SiteEmail

cohtml.Net.IVirtualAllocator

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

Inherits from SystemIDisposable

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.
Name
boolswigCMemOwn
virtual void Dispose()
virtual ulong GetAllocationPageSize()
virtual ulong GetCommitPageSize()
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.

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.

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.

bool swigCMemOwn;