MemoryHeap

MemoryHeap
Scaleform::MemoryHeap
Declaration
class MemoryHeap : public ListNode<MemoryHeap>;
Description

The memory heap from which allocations take place. This interface supports creation of child heaps for dedicated purposes, such that when child heaps are released all of their memory is released as well. The benefit of child heaps is that they grab memory in large chunks of Granularity from the root, such that all of heap-local allocations take place in those chunks. This strategy reduces overall fragmentation, since once child heap is released it will make all of its large chunks available for reuse. 

The child memory heap use in GFx relies on ability to determine target heap based on the address within allocation in it, done by AllocAutoHeap function. This function takes an address that must be within some other allocation of the desired heap and allocated new memory within the same heap as that allocation. Note that the passed address does NOT have to point to the head of previous allocation, it can also be in the middle of it. This functionality allows convenient initialization of aggregate structures and arrays located within other objects, and their allocations will automatically take place within the same heap as the containing object. 

Internally, heaps rely on SysAlloc/SysAllocPaged interface for allocating large blocks of system memory; this interface is specified in Scaleform::GFx::System/Scaleform::System constructor. Developers can substitute GFx allocator by re-implementing SysAlloc/SysAllocPaged interface.

Enumerations
Enumeration 
Description 
Lists the different types of memory report that can be generated. 
Flag bits set to indicate if the heap is root heap, thread safe, uses debug mode and so on. 
Provides the parameters set for the root memory heap. 
Methods
Method 
Description 
Increments the heap reference count. 
Allocates memory block. If size is 0, Alloc will allocate a tiny block and return a valid pointer. 
Allocates memory block while automatically identifying heap and allocation id based on the specified address. 
Allocates memory block directly from the system allocator. 
Checks if the memory arena is empty. 
Assigns heap to current thread causing ASSERTs if called for other thread. 
 
Creates a memory arena that can be used by the heap for allocation purposes. 
Creates a nested child heap. The heap should be destroyed by calling Release
Releases the memory block allocated for the root heap in the malloc based memory allocations. 
Releases the memory block allocated for the root heap in page based memory allocation. 
Creates the root heap in the malloc based memory allocations. 
Creates the root heap in the page based memory allocations. 
Destroys the memory arena created for the heap. 
Traverses through all child heaps and dumps memory leaks. 
Free 
Frees the memory allocated for a resource. 
Releases the memory block allocated directly from the system allocator by AllocSysDirect
Determines which heap the allocation belongs to. 
Determine which heap allocation belongs to 
Returns the flags set for the heap. 
Returns the number of bytes allocated from the system for the heap. 
Returns the granularity size of the heap allocations. 
Fills in the heap descriptor with information. 
Returns the Id of the memory heap. 
Returns the memory limit on the heap. 
Returns the minimum alignment enforced for all allocations from heap. 
Returns the name of the memory heap. 
Returns the parent heap used for allocation. 
Obtains the allocation statistics pertaining to the root heap. 
Obtains the memory statistics for the heap. 
Returns the total amount of memory allocation for the parent and nested child heaps. 
Recursively iterates through all child heaps and sums up the total used space. 
Returns the actual allocation size that can be safely used. 
Returns the actual amount of allocated bytes in a heap. 
Initializes the root memory heap for heaps in malloc based memory allocations. 
Initializes the root memory heap for heaps in page based memory allocations. 
Determines if the heap is thread safe or not. 
Generates a brief or detailed GFx memory heap report within a string buffer. 
Reallocates memory set by Alloc
Releases the heap and deallocates it unless there are other references to the heap. 
Releases cached memory segments from all heaps. 
Marks allocation for automatic cleanup of heap. 
Releases the root heap and/or de-initializes it. 
Releases the root heap and/or de-initializes it. 
Sets the limit handler for handling memory limit exceeds. 
Sets a fixed memory limit on the allocation size. 
Enumerates all of the child heaps by calling HeapVisitor::Visit
Structures
Structure 
Description 
Structure providing description of memory heap created. 
Heap descriptor used to indicate the attributes of the heap. 
Heap visitor for calling child heaps within each parent heap. 
Handler for handling memory limit exceeds. 
Root heap descriptor and used for initializing a root heap object. 
Structure used to indicate the memory allocation statistics of the root heap. 
File

SF_MemoryHeap.h