Photon Quantum 3.0.0

Classes | Public Member Functions | Static Public Member Functions | Properties | List of all members
Quantum.Allocator.Heap Struct Reference

The Quantum heap is a custom memory allocator that contains rollback-able memory allocations by Quantum user or internal systems. It implements the ITrackableFrameHeap interface for memory leak tracking. More...

Inheritance diagram for Quantum.Allocator.Heap:
Quantum.Allocator.ITrackableFrameHeap Quantum.Allocator.IFrameHeap

Classes

struct  Config
 The configuration of the frame heap. More...
 
struct  Stats
 Statistics of the heap. More...
 

Public Member Functions

void * Allocate (Int32 size)
 Allocate memory on the heap with a given size. More...
 
void * Allocate< T > (int size, T allocTracker)
 Allocate memory on the heap. More...
 
void * AllocateAndClear (Int32 size)
 Allocate memory on the heap with a given size and clear the memory. More...
 
void * AllocateAndClear< T > (int size, T allocTracker)
 Allocate a void* with a given size and clear the memory. More...
 
Ptr AllocateAndClearPtr (Int32 size)
 Allocate a Ptr of a given size and clear the memory. More...
 
Ptr AllocateAndClearPtr< T > (int size, T allocTracker)
 Allocate a Ptr with a given size and clear the memory. More...
 
Ptr AllocatePtr (Int32 size)
 Allocate a Ptr of a given size. More...
 
Ptr AllocatePtr< T > (int size, T allocTracker)
 Allocate a Ptr with a given size. More...
 
void * Expand (void *buffer, Int32 currentSize, Int32 newSize)
 Grow an allocated array and copy the content to the new array. More...
 
void * Expand< T > (void *buffer, int currentSize, int newSize, T allocTracker)
 Grow an allocated array of type T. The content is copied to the new array. More...
 
T * ExpandArray< T > (T *buffer, Int32 currentSize, Int32 newSize)
 Grow an allocated array of type T and copy the content to the new array. More...
 
T * ExpandArray< T, TTracker > (T *buffer, int currentSize, int newSize, TTracker allocTracker)
 Grow an allocated array of type T. The content is copied to the new array. More...
 
void Free (Ptr ptr)
 Free a Ptr from the heap memory. More...
 
void Free (void *ptr)
 Free a block of memory from the heap. More...
 
void Free< T > (Ptr ptr, T allocTracker)
 Free a ptr from the heap memory. More...
 
void Free< T > (void *ptr, T allocTracker)
 Free a block of memory from the heap. More...
 
void * Void (Ptr p)
 Converts a Ptr to a void pointer. More...
 
Ptr Void (void *ptr)
 Converts a pointer to a Ptr. More...
 
T * Void< T > (Ptr p)
 Converts a Ptr to a typed pointer. More...
 
- Public Member Functions inherited from Quantum.Allocator.IFrameHeap
void * Allocate (int size)
 Allocates a block of memory of the specified size. More...
 
void * AllocateAndClear (int size)
 Allocates a block of memory of the specified size and clears it. More...
 
Ptr AllocateAndClearPtr (int size)
 Allocates a Ptr for a block of memory of the specified size and clears it. More...
 
Ptr AllocatePtr (int size)
 Allocates a Ptr for a block of memory of the specified size. More...
 
void * Expand (void *buffer, int currentSize, int newSize)
 Expands a memory block in the given buffer to the specified new size. More...
 
T * ExpandArray< T > (T *buffer, int currentSize, int newSize)
 Expands an array in the given buffer to the specified new size. More...
 
TPtr * Void< TPtr > (Ptr p)
 Converts a Ptr to a typed pointer. More...
 

Static Public Member Functions

static byte[] Blit (Heap *heap)
 Obsolete. More...
 
static void Blit (Heap *heap, byte[] byteBlocks, Native.Allocator allocator)
 Obsolete. More...
 
static void Copy (Native.Allocator allocator, Heap *to, Heap *from)
 Copies the complete frame heap from one heap to another. More...
 
static ulong CRC (ulong crc, Heap *heap)
 Obsolete. More...
 
static Stats GetStats (Heap *heap)
 Generates a compact statistic report about the memory usage. More...
 
static void Print (Heap *heap, FramePrinter printer)
 Prints the frame heap using a FramePrinter. More...
 
static void Reset ()
 Reset the heap. More...
 

Properties

byte * Memory [get]
 Get direct access to the memory of the heap. More...
 
bool? Reserved [get, set]
 Set and get the reserved flag. More...
 
int Size [get]
 Returns the heap size set by the Heap.Config.HEAP_SIZE. More...
 

Detailed Description

The Quantum heap is a custom memory allocator that contains rollback-able memory allocations by Quantum user or internal systems. It implements the ITrackableFrameHeap interface for memory leak tracking.

Member Function Documentation

◆ AllocatePtr< T >()

Ptr Quantum.Allocator.Heap.AllocatePtr< T > ( int  size,
allocTracker 
)
inline

Allocate a Ptr with a given size.

Template Parameters
TTracker type
Parameters
sizeAllocation size
allocTrackerAlloc tracker instance
Returns
Ptr to Quantum heap memory

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ AllocateAndClearPtr< T >()

Ptr Quantum.Allocator.Heap.AllocateAndClearPtr< T > ( int  size,
allocTracker 
)
inline

Allocate a Ptr with a given size and clear the memory.

Template Parameters
TTracker type
Parameters
sizeAllocation size
allocTrackerAlloc tracker instance
Returns
Ptr to Quantum heap memory

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ AllocateAndClear< T >()

void* Quantum.Allocator.Heap.AllocateAndClear< T > ( int  size,
allocTracker 
)
inline

Allocate a void* with a given size and clear the memory.

Template Parameters
TTracker type
Parameters
sizeAllocation size
allocTrackerAlloc tracker instance
Returns
Ptr to Quantum heap memory

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ ExpandArray< T, TTracker >()

T* Quantum.Allocator.Heap.ExpandArray< T, TTracker > ( T *  buffer,
int  currentSize,
int  newSize,
TTracker  allocTracker 
)
inline

Grow an allocated array of type T. The content is copied to the new array.

Template Parameters
TArray type
TTrackerTracker type
Parameters
bufferArray
currentSizeCurrent array size
newSizeNew array size
allocTrackerAllocation tracker
Returns
New array

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :unmanaged 
TTracker :IHeapAllocationTracker 

◆ Expand< T >()

void* Quantum.Allocator.Heap.Expand< T > ( void *  buffer,
int  currentSize,
int  newSize,
allocTracker 
)
inline

Grow an allocated array of type T. The content is copied to the new array.

Template Parameters
TTacker type
Parameters
bufferArray
currentSizeCurrent array size
newSizeNew array size
allocTrackerAllocation tracker
Returns
New array

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ Allocate< T >()

void* Quantum.Allocator.Heap.Allocate< T > ( int  size,
allocTracker 
)
inline

Allocate memory on the heap.

Template Parameters
TTracker type
Parameters
sizeAllocation size
allocTrackerAlloc tracker
Returns
Allocated memory
Exceptions
ArgumentExceptionAllocated size is larger than the max size defined by the SimulationConfig.

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ Allocate()

void* Quantum.Allocator.Heap.Allocate ( Int32  size)
inline

Allocate memory on the heap with a given size.

Parameters
sizeSize in bytes
Returns
Allocated memory.

◆ AllocatePtr()

Ptr Quantum.Allocator.Heap.AllocatePtr ( Int32  size)
inline

Allocate a Ptr of a given size.

Parameters
sizeSize
Returns
Allocated Ptr

◆ AllocateAndClear()

void* Quantum.Allocator.Heap.AllocateAndClear ( Int32  size)
inline

Allocate memory on the heap with a given size and clear the memory.

Parameters
sizeSize
Returns
Allocated memory

◆ AllocateAndClearPtr()

Ptr Quantum.Allocator.Heap.AllocateAndClearPtr ( Int32  size)
inline

Allocate a Ptr of a given size and clear the memory.

Parameters
sizeSize
Returns
Allocated Ptr

◆ ExpandArray< T >()

T* Quantum.Allocator.Heap.ExpandArray< T > ( T *  buffer,
Int32  currentSize,
Int32  newSize 
)
inline

Grow an allocated array of type T and copy the content to the new array.

Template Parameters
TArray type
Parameters
bufferArray
currentSizeCurrent array size
newSizeNew array size
Returns
New array
Type Constraints
T :unmanaged 

◆ Expand()

void* Quantum.Allocator.Heap.Expand ( void *  buffer,
Int32  currentSize,
Int32  newSize 
)
inline

Grow an allocated array and copy the content to the new array.

Parameters
bufferArray
currentSizeCurrent array size
newSizeNew array size
Returns
New array

◆ Blit() [1/2]

static byte [] Quantum.Allocator.Heap.Blit ( Heap heap)
inlinestatic

Obsolete.

◆ Blit() [2/2]

static void Quantum.Allocator.Heap.Blit ( Heap heap,
byte[]  byteBlocks,
Native.Allocator  allocator 
)
inlinestatic

Obsolete.

◆ CRC()

static ulong Quantum.Allocator.Heap.CRC ( ulong  crc,
Heap heap 
)
inlinestatic

Obsolete.

◆ GetStats()

static Stats Quantum.Allocator.Heap.GetStats ( Heap heap)
inlinestatic

Generates a compact statistic report about the memory usage.

Parameters
heapPointer to heap to analyze.
Returns
Memory statistics

◆ Copy()

static void Quantum.Allocator.Heap.Copy ( Native.Allocator  allocator,
Heap to,
Heap from 
)
inlinestatic

Copies the complete frame heap from one heap to another.

Parameters
allocatorAllocator instance
toDestination heap
fromSource heap
Exceptions
InvalidOperationExceptionIs thrown when the heaps have different configurations.

◆ Print()

static void Quantum.Allocator.Heap.Print ( Heap heap,
FramePrinter  printer 
)
inlinestatic

Prints the frame heap using a FramePrinter.

Parameters
heapPointer to heap instance
printerPrinter object

◆ Free< T >() [1/2]

void Quantum.Allocator.Heap.Free< T > ( Ptr  ptr,
allocTracker 
)
inline

Free a ptr from the heap memory.

Template Parameters
TType of allocation tracker
Parameters
ptrPtr
allocTrackerAllocation tracker instance

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ Free< T >() [2/2]

void Quantum.Allocator.Heap.Free< T > ( void *  ptr,
allocTracker 
)
inline

Free a block of memory from the heap.

Template Parameters
TType of allocation tracker
Parameters
ptrMemory to free
allocTrackerAllocation tracker instance

Implements Quantum.Allocator.ITrackableFrameHeap.

Type Constraints
T :IHeapAllocationTracker 

◆ Free() [1/2]

void Quantum.Allocator.Heap.Free ( void *  ptr)
inline

Free a block of memory from the heap.

Parameters
ptrMemory block

Implements Quantum.Allocator.IFrameHeap.

◆ Free() [2/2]

void Quantum.Allocator.Heap.Free ( Ptr  ptr)
inline

Free a Ptr from the heap memory.

Parameters
ptrPtr

Implements Quantum.Allocator.IFrameHeap.

◆ Reset()

static void Quantum.Allocator.Heap.Reset ( )
inlinestatic

Reset the heap.

◆ Void() [1/2]

Ptr Quantum.Allocator.Heap.Void ( void *  ptr)
inline

Converts a pointer to a Ptr.

Parameters
ptrVoid pointer
Returns
Ptr

Implements Quantum.Allocator.IFrameHeap.

◆ Void() [2/2]

void* Quantum.Allocator.Heap.Void ( Ptr  p)
inline

Converts a Ptr to a void pointer.

Parameters
pPtr
Returns
Pointer

Implements Quantum.Allocator.IFrameHeap.

◆ Void< T >()

T* Quantum.Allocator.Heap.Void< T > ( Ptr  p)
inline

Converts a Ptr to a typed pointer.

Template Parameters
TType of pointer
Parameters
pPtr
Returns
Pointer of type
Type Constraints
T :unmanaged 

Property Documentation

◆ Reserved

bool? Quantum.Allocator.Heap.Reserved
getset

Set and get the reserved flag.

◆ Memory

byte* Quantum.Allocator.Heap.Memory
get

Get direct access to the memory of the heap.

◆ Size

int Quantum.Allocator.Heap.Size
get

Returns the heap size set by the Heap.Config.HEAP_SIZE.