XMem API Reference

Reference material for memory allocation APIs.

There are two functions which the operating system and middleware can call to perform memory operations which can be hooked by your title – XMemAlloc to allocate memory, and XMemFree to free blocks which were previously allocated by a call to XMemAlloc. Both of these functions take a dwAttributes parameter which identifies the type of allocation, the subsystem performing the allocation, and define the parameters which need to be honored for the allocation itself. The default implementations of these functions are XMemAllocDefault and XMemFreeDefault, which can be called by your title if it does not understand the kind of allocation being requested. Alternatively, you may wish to leave the entire implementation to the operating system and always call the default functions, using the hooks solely to track allocations and frees for debugging purposes.

Functions

Name Description
AllocateTitlePhysicalPages Allocates the requested amount of memory in separate contiguous runs.
FreeTitlePhysicalPages Used to free pages allocated with AllocateTitlePhysicalPages.
MAKE_XALLOC_ATTRIBUTES Inline helper function used to compose the dwAttributes parameter to XMEMALLOC_ROUTINE.
MapTitlePhysicalPages Maps pages allocated by AllocateTitlePhysicalPages into the virtual address space.
TitleMemoryStatus Retrieves information about the current usage of memory accessible to the title.
VirtualAlloc Application-defined memory allocation callback function that replaces the default memory allocator.
VirtualFree Releases or decommits a region of pages within the virtual address space of the calling process.
XMemAlloc Application-defined memory allocation callback function that replaces the default memory allocator.
XMEMALLOC_ROUTINE Defines the syntax of the memory allocation routines, XMemAlloc and XMemAllocDefault.
XMemAllocDefault The default memory allocation routine.
XMemFree Application-defined memory deallocation callback function that replaces the default memory deallocator.
XMEMFREE_ROUTINE Defines the syntax of the memory deallocation routines, XMemFree and XMemFreeDefault.
XMemFreeDefault Default memory free function.
XMemGetAllocationHysteresis Gets the hysteresis amount for a given heap, rounded up to an internal allocation boundary (4 MB).
XMemGetAllocationStatistics Queries the hysteresis amount for a given heap.
XMemPreallocateFreeSpace Allocates free pages for a heap up to its hysteresis value.
XMemSetAllocationHooks Used by titles to register memory allocation hooks.
XMemSetAllocationHysteresis Sets the hysteresis amount for a given heap, rounded up to an internal allocation boundary (4 MB).

Structures

Name Description
TITLEMEMORYSTATUS Describes the current usage of memory accessible to the title.
XALLOC_ATTRIBUTES Contains values that describe the attributes of a memory allocation.
XMEM_HEAP_STATISTICS A statistics structure for a given heap.

Enumerations

Name Description
XALLOC_ALLOCATOR_IDS Defines the range for the set of IDs for different types of allocators used by memory allocation routines.

See also

White Paper: Xbox One XDK Memory Management

White Paper: Xbox One Memory System