> ## 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.

# XMemSetAllocationHooks

> XMemSetAllocationHooks

# XMemSetAllocationHooks

This API has been deprecated. Please refer to [XMEM\_ALLOCATION\_HOOKS](/reference/system/xmem/structs/xmem_allocation_hooks) instead.

Used by titles to register memory allocation hooks.

## Syntax

```cpp theme={null}
VOID XMemSetAllocationHooks(  
         PXMEMALLOC_ROUTINE AllocRoutine,  
         PXMEMFREE_ROUTINE FreeRoutine  
)  
```

### Parameters

*AllocRoutine*   \_In\_\
Type: PXMEMALLOC\_ROUTINE

Pointer to the title's allocation function. See the [XMEMALLOC\_ROUTINE](/reference/system/xmem/functions/xmemalloc_routine) topic for the definition of this function.

*FreeRoutine*   \_In\_\
Type: PXMEMFREE\_ROUTINE

Pointer to the title's deallocation function. See the [XMEMFREE\_ROUTINE](/reference/system/xmem/functions/xmemfree_routine) topic for the definition of this function.

### Return value

Type: VOID

## Remarks

Allocations can be monitored (or overridden) with a title provided callback through the **XMemSetAllocationHooks** function. With proper use of this API, titles can track nearly every allocation made from the title code as well as the majority of 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](/reference/system/xmem/functions/xmemalloc_routine) and [XMEMFREE\_ROUTINE](/reference/system/xmem/functions/xmemfree_routine) if you hook them; hooking only one of them will be considered an error.

## Requirements

**Header:** xmem.h

**Library:** xmem.lib

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

## See also

[XMem reference](/reference/system/xmem/xmem_members)\
[XMEMALLOC\_ROUTINE](/reference/system/xmem/functions/xmemalloc_routine)\
[XMEMFREE\_ROUTINE](/reference/system/xmem/functions/xmemfree_routine)


## Related topics

- [XMEM_ALLOCATION_HOOKS](/reference/system/xmem/structs/xmem_allocation_hooks.md)
- [XMemSetWin32HeapTrackingHooks](/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks.md)
- [XMemFreeDefault](/reference/system/xmem/functions/xmemfreedefault.md)
- [PFMemSetFunctions](/services/playfab/api-references/c/pfplatform/functions/pfmemsetfunctions.md)
- [PFMemoryHooks](/services/playfab/api-references/c/pfplatform/structs/pfmemoryhooks.md)
