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

# XMEM_ALLOCATION_HOOKS

> XMEM_ALLOCATION_HOOKS

# XMEM\_ALLOCATION\_HOOKS

表示游戏的内存分配和释放函数的挂钩。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
typedef struct XMEM_ALLOCATION_HOOKS {  
    PXMEMALLOC_ROUTINE AllocRoutine;  
    PXMEMFREE_ROUTINE FreeRoutine;  
} XMEM_ALLOCATION_HOOKS  
```

<a id="membersSection" />

### 成员

*AllocRoutine*\
类型：PXMEMALLOC\_ROUTINE

指向游戏的分配函数的指针。有关实现应用程序定义的内存分配函数的详细信息，请参阅 [XMEMALLOC\_ROUTINE](/reference/system/xmem/functions/xmemalloc_routine) 和 [XMemAlloc](/reference/system/xmem/functions/xmemalloc)。

*FreeRoutine*\
类型：PXMEMFREE\_ROUTINE

指向游戏的释放函数的指针。有关实现应用程序定义的内存释放函数的详细信息，请参阅 [XMEMFREE\_ROUTINE](/reference/system/xmem/functions/xmemfree_routine) 和 [XMemFree](/reference/system/xmem/functions/xmemfree)。

<a id="remarksSection" />

## 备注

此结构由 [XMEM\_SET\_ALLOCATION\_HOOKS](/reference/system/xmem/macros/xmem_set_allocation_hooks) 宏使用，用于为你的游戏注册应用程序定义的内存分配和释放函数。有关图形内存的详细信息，请参阅 [GDK 图形内存概述](/build/core-features/graphics/graphics-memory-overview)。

<Note>[XMemSetAllocationHooks](/reference/system/xmem/functions/xmemsetallocationhooks) 函数已被弃用。请使用此宏代替 `XMemSetAllocationHooks` 函数来注册游戏的内存分配和释放函数。</Note>

<a id="requirementsSection" />

## 要求

**头文件：** xmem.h

**支持的平台：** XBOX One 系列主机和 XBOX Series 主机

<a id="seealsoSection" />

## 另请参阅

[XMEM\_SET\_ALLOCATION\_HOOKS](/reference/system/xmem/macros/xmem_set_allocation_hooks)\
[XMEMALLOC\_ROUTINE](/reference/system/xmem/functions/xmemalloc_routine)\
[XMEMFREE\_ROUTINE](/reference/system/xmem/functions/xmemfree_routine)\
[XMem](/reference/system/xmem/xmem_members)


## Related topics

- [XMemSetAllocationHooks](/zh-CN/reference/system/xmem/functions/xmemsetallocationhooks.md)
- [XMemFreeDefault](/zh-CN/reference/system/xmem/functions/xmemfreedefault.md)
- [XMEMALLOC_ROUTINE callback](/zh-CN/reference/system/xmem/functions/xmemalloc_routine.md)
- [XMEMFREE_ROUTINE callback](/zh-CN/reference/system/xmem/functions/xmemfree_routine.md)
- [XMemSetWin32HeapTrackingHooks](/zh-CN/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks.md)
