> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PHEAP_TRACK_ALLOC_ROUTINE callback

> PHEAP_TRACK_ALLOC_ROUTINE callback

# PHEAP\_TRACK\_ALLOC\_ROUTINE callback

Represents a tracking callback function for heap allocation.

<a id="syntaxSection" />

## Syntax

```cpp theme={null}
void PHEAP_TRACK_ALLOC_ROUTINE(  
         HANDLE Heap,  
         DWORD Flags,  
         SIZE_T Size,  
         PVOID Addr  
)  
```

<a id="parametersSection" />

### Parameters

*Heap*   \
Type: HANDLE

The handle to the heap from which the memory block was allocated.

*Flags*   \
Type: DWORD

The heap allocation flags passed to [HeapAlloc](https://learn.microsoft.com/windows/desktop/api/heapapi/nf-heapapi-heapalloc).

*Size*   \
Type: SIZE\_T

The number of bytes allocated for the memory block.

*Addr*   \
Type: PVOID

The address of the allocated memory block.

<a id="retvalSection" />

### Return value

Type: void

None.

<a id="remarksSection" />

## Remarks

This callback function can be implemented to track when a memory block is allocated from a Win32 heap. Once implemented, you must register the implemented callback function by calling [XMemSetWin32HeapTrackingHooks](/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks). The callback function is then invoked after `HeapAlloc` is called to allocate a block of memory from a Win32 heap. For more information about implementing this callback function, see the [Remarks](/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks#remarksSection) section of `XMemSetWin32HeapTrackingHooks`.

<a id="requirementsSection" />

## Requirements

**Header:** xmem.h

**Library:** xmem.lib

**Supported platforms:** XBOX One family consoles and XBOX Series consoles

<a id="seealsoSection" />

## See also

[Diagnostics and memory tracking](/build/console-features/memory/system-memory-diagnostics)\
[XMemCreateWin32Heap](/reference/system/xmem/functions/xmemcreatewin32heap)\
[PHEAP\_TRACK\_FREE\_ROUTINE](/reference/system/xmem/functions/pheap_track_free_routine)\
[PHEAP\_TRACK\_REALLOC\_ROUTINE](/reference/system/xmem/functions/pheap_track_realloc_routine)\
[XMem](/reference/system/xmem/xmem_members)


## Related topics

- [XMemSetWin32HeapTrackingHooks](/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks.md)
- [PHEAP_TRACK_FREE_ROUTINE callback](/reference/system/xmem/functions/pheap_track_free_routine.md)
- [PHEAP_TRACK_REALLOC_ROUTINE callback](/reference/system/xmem/functions/pheap_track_realloc_routine.md)
- [XMEMALLOC_ROUTINE callback](/reference/system/xmem/functions/xmemalloc_routine.md)
- [XMEMFREE_ROUTINE callback](/reference/system/xmem/functions/xmemfree_routine.md)
