XMEM_SET_ALLOCATION_HOOKS
Used by titles to register memory allocation hooks.Syntax
Parameters
AllocRoutine In Type: PXMEMALLOC_ROUTINE Pointer to the title’s allocation function. See the XMEMALLOC_ROUTINE topic for the definition of this function. FreeRoutine InType: PXMEMFREE_ROUTINE Pointer to the title’s deallocation function. See the XMEMFREE_ROUTINE topic for the definition of this function.
Remarks
Allocations can be monitored (or overridden) with a title provided callback through the XMEM_SET_ALLOCATION_HOOKS macro. With proper use of this macro, titles can track every allocation made from the title code as well as the platform code. If titles choose not to provide their own allocation hooks, XMemAllocDefault and XMemFreeDefault will be used instead (see xmem.h for the declaration of these hooks.) If titles desire to provide allocation hooks for the sake of tracking, but do not wish to implement their own allocator, they can call into the default allocator directly. It is important to provide an implementation for both XMEMALLOC_ROUTINE and XMEMFREE_ROUTINE if you hook them; hooking only one of them will be considered an error. The title provided hooks are exported from the game executable and are bound at load time of xmem.dll (normally the time that the game is launched).The functions registered by XMemSetAllocationHooks must be defined within the game exe to ensure that the addresses are statically populated. If the function pointers provided refer to functions in DLLs that is referenced by the game exe, the compiler must emit static initializer code to populate the memory that may execute after the platform has queried for the override hooks resulting in unpredictable behavior. A warning will appear in the debugger output window if the platform detects this may have occurred.
Requirements
Header: xmem.h Supported platforms: XBOX One family consoles and XBOX Series consolesSee also
XMem referenceXMEM_ALLOCATION_HOOKS
XMEMALLOC_ROUTINE
XMEMFREE_ROUTINE
