Class Heap
Heap class.
Inheritance
Inherited Members
Namespace: Cosmos.Core.Memory
Assembly: Cosmos.Core.dll
Syntax
public static class Heap
Methods
| Improve this Doc View SourceAlloc(UInt32)
Alloc memory block, of a given size.
Declaration
public static byte *Alloc(uint aSize)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aSize | A size of block to alloc, in bytes. |
Returns
Type | Description |
---|---|
System.Byte* | Byte pointer to the start of the block. |
Collect()
Collects all unreferenced objects after identifying them first
Declaration
public static int Collect()
Returns
Type | Description |
---|---|
System.Int32 | Number of objects freed |
Free(Void*)
Free a heap item.
Declaration
public static void Free(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr | A pointer to the heap item to be freed. |
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown if:
|
Init()
Init heap.
Declaration
public static void Init()
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown on fatal error, contact support. |
MarkAndSweepObject(Void*)
Marks a GC managed object as referenced and recursivly marks child objects as well
Declaration
public static void MarkAndSweepObject(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr |
Realloc(Byte*, UInt32)
Re-allocates or "re-sizes" data asigned to a pointer. The pointer specified must be the start of an allocated block in the heap. This shouldn't be used with objects as a new address is given when realocating memory.
Declaration
public static byte *Realloc(byte *aPtr, uint newSize)
Parameters
Type | Name | Description |
---|---|---|
System.Byte* | aPtr | Existing pointer |
System.UInt32 | newSize |
Returns
Type | Description |
---|---|
System.Byte* | New pointer with specified size while maintaining old data. |
SafeAlloc(UInt32)
Allocates memory and returns the pointer as uint
Declaration
public static uint SafeAlloc(uint aSize)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aSize | Size of memory to allocate |
Returns
Type | Description |
---|---|
System.UInt32 |
SweepTypedObject(UInt32*, UInt32)
Marks all objects referenced
Declaration
public static void SweepTypedObject(uint *obj, uint type)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32* | obj | |
System.UInt32 | type |