Class HeapSmall
HeapSmall class. Used to alloc and free small memory blocks on the heap.
Inheritance
System.Object
HeapSmall
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Cosmos.Core.Memory
Assembly: Cosmos.Core.dll
Syntax
public static class HeapSmall
Fields
| Improve this Doc View SourcemMaxItemSize
Max item size in the heap.
Declaration
public static uint mMaxItemSize
Field Value
Type | Description |
---|---|
System.UInt32 |
PrefixItemBytes
Number of prefix bytes for each item. We technically only need 2 but to keep it aligned we have two padding
Declaration
public const uint PrefixItemBytes = 4U
Field Value
Type | Description |
---|---|
System.UInt32 |
SMT
Size map table
Declaration
public static SMTPage*SMT
Field Value
Type | Description |
---|---|
SMTPage* |
Methods
| Improve this Doc View SourceAlloc(UInt16)
Alloc memory block, of a given size.
Declaration
public static byte *Alloc(ushort aSize)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16 | aSize | A size of block to alloc, in bytes. |
Returns
Type | Description |
---|---|
System.Byte* | Byte pointer to the start of the block. |
Free(Void*)
Free a object
Declaration
public static void Free(void *aPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | aPtr | A pointer to the start object. |
GetAllocatedObjectCount()
Counts how many elements are currently allocated
Declaration
public static int GetAllocatedObjectCount()
Returns
Type | Description |
---|---|
System.Int32 |
GetRoundedSize(UInt32)
Return the size a certain element will be allocated as
Declaration
public static uint GetRoundedSize(uint aSize)
Parameters
Type | Name | Description |
---|---|---|
System.UInt32 | aSize |
Returns
Type | Description |
---|---|
System.UInt32 |
Init()
Init small heap.
Declaration
public static void Init()
Exceptions
Type | Condition |
---|---|
System.Exception | Thrown on fatal error, contact support. |
PruneSMT()
This function will free all pages allocated for small objects which are emnpty
Declaration
public static int PruneSMT()
Returns
Type | Description |
---|---|
System.Int32 | Number of pages freed |