Skip to main content

XMemSetWin32HeapTrackingHooks

Sets tracking callback functions for memory allocation, reallocation, and deallocation of Win32 heaps.

Syntax

Parameters

AllocRoutine   _In_
Type: PHEAP_TRACK_ALLOC_ROUTINE
A pointer to a tracking callback function for memory allocation. ReAllocRoutine   _In_
Type: PHEAP_TRACK_REALLOC_ROUTINE
A pointer to a tracking callback function for memory reallocation. FreeRoutine   _In_
Type: PHEAP_TRACK_FREE_ROUTINE
A pointer to a tracking callback function for memory deallocation.

Return value

Type: VOID None.

Remarks

This function allows you to track Win32 heap memory allocation, reallocation, and deallocation by specifying callback functions that are invoked by the GDK memory manager when those heap memory operations are called. For more information about tracking memory operations, see Diagnostics and memory tracking.
The CRT makes several heap allocations during initialization and entry points of DLLs/EXEs linked with the CRT. Since this initialization is a pre-requisite for execution of any code within these modules, it is not typically possible to call XMemSetWin32HeapTrackingHooks prior to all heap allocations occurring. Callback code should be aware of this behavior and handle it accordingly.
Before calling this function, you must first implement the following corresponding tracking callback functions: You only need to implement those tracking callback functions required for your tracking requirements. To stop tracking heap memory operations, call this function and specify NULL for the appropriate heap memory operations you want to stop tracking. The following example defines tracking callback functions, then uses the XMemSetWin32HeapTrackingHooks function to set and clear hooks to those tracking callback functions.

Requirements

Header: xmem.h Library: xmem.lib Supported platforms: XBOX One family consoles and XBOX Series consoles

See also

Memory
XMem
Last modified on August 20, 2026