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

> XMem

# XMem

内存 API 的参考资料。

## 函数

| 函数                                                                                                | 描述                                                                                                        |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [PHEAP\_TRACK\_ALLOC\_ROUTINE 回调](/reference/system/xmem/functions/pheap_track_alloc_routine)     | 表示堆分配的跟踪回调函数。                                                                                             |
| [PHEAP\_TRACK\_FREE\_ROUTINE 回调](/reference/system/xmem/functions/pheap_track_free_routine)       | 表示堆释放的跟踪回调函数。                                                                                             |
| [PHEAP\_TRACK\_REALLOC\_ROUTINE 回调](/reference/system/xmem/functions/pheap_track_realloc_routine) | 表示堆重新分配的跟踪回调函数。                                                                                           |
| [XMemAlloc](/reference/system/xmem/functions/xmemalloc)                                           | 表示替换默认内存分配器的应用程序定义的内存分配回调函数。                                                                              |
| [XMEMALLOC\_ROUTINE 回调](/reference/system/xmem/functions/xmemalloc_routine)                       | 定义内存分配例程 [XMemAlloc](/reference/system/xmem/functions/xmemalloc) 和 `XMemAllocDefault` 的语法。                |
| [XMemAllocatePhysicalPages](/reference/system/xmem/functions/xmemallocatephysicalpages)           | 为指定的目标进程分配连续的物理页。                                                                                         |
| [XMemAllocDefault](/reference/system/xmem/functions/xmemallocdefault)                             | 默认内存分配例程。                                                                                                 |
| [XMemCreateWin32Heap](/reference/system/xmem/functions/xmemcreatewin32heap)                       | 创建 Win32 堆。                                                                                               |
| [XMemFree](/reference/system/xmem/functions/xmemfree)                                             | 定义内存释放例程。                                                                                                 |
| [XMEMFREE\_ROUTINE 回调](/reference/system/xmem/functions/xmemfree_routine)                         | 定义内存释放例程 [XMemFree](/reference/system/xmem/functions/xmemfree) 和 `XMemFreeDefault` 的语法。                   |
| [XMemFreeDefault](/reference/system/xmem/functions/xmemfreedefault)                               | 默认内存释放例程。                                                                                                 |
| [XMemFreePhysicalPages](/reference/system/xmem/functions/xmemfreephysicalpages)                   | 将使用 [XMemAllocatePhysicalPages](/reference/system/xmem/functions/xmemallocatephysicalpages) 分配的页释放回内存管理器。 |
| [XMemGetAllocationHysteresis](/reference/system/xmem/functions/xmemgetallocationhysteresis)       | 获取给定堆的滞后量，向上舍入到内部分配边界。                                                                                    |
| [XMemGetAllocationStatistics](/reference/system/xmem/functions/xmemgetallocationstatistics)       | 获取给定堆的统计信息。                                                                                               |
| [XMemGetPhysicalMemoryLayout](/reference/system/xmem/functions/xmemgetphysicalmemorylayout)       | 获取物理内存布局。                                                                                                 |
| [XMemGetTitleHeap](/reference/system/xmem/functions/xmemgettitleheap)                             | 返回指向游戏堆的指针。                                                                                               |
| [XMemGetWin32HeapName](/reference/system/xmem/functions/xmemgetwin32heapname)                     | XMemGetWin32HeapName API 文档                                                                               |
| [XMemGetWin32HeapStatistics](/reference/system/xmem/functions/xmemgetwin32heapstatistics)         | 获取给定 Win32 堆的统计信息。                                                                                        |
| [XMemGetWorkingSetStatistics](/reference/system/xmem/functions/xmemgetworkingsetstatistics)       | 提供游戏进程中内存精确使用情况的详细信息。                                                                                     |
| [XMemGetWriteWatch](/reference/system/xmem/functions/xmemgetwritewatch)                           | XMemGetWriteWatch API 文档                                                                                  |
| [XMemIsToolsMemAvailable](/reference/system/xmem/functions/xmemistoolsmemavailable)               | 指示工具内存是否可用。                                                                                               |
| [XMemMakeTag](/reference/system/xmem/functions/xmemmaketag)                                       | 根据四字符代码创建 24 位标签。                                                                                         |
| [XMemMapPhysicalPages](/reference/system/xmem/functions/xmemmapphysicalpages)                     | 将由 [XMemAllocatePhysicalPages](/reference/system/xmem/functions/xmemallocatephysicalpages) 分配的页映射到虚拟地址空间。 |
| [XMemMapPhysicalPagesScatter](/reference/system/xmem/functions/xmemmapphysicalpagesscatter)       | 将物理页映射到虚拟内存中。                                                                                             |
| [XMemPreallocateFreeSpace](/reference/system/xmem/functions/xmempreallocatefreespace)             | 为堆分配达到其滞后值的空闲页。                                                                                           |
| [XMemResetWriteWatch](/reference/system/xmem/functions/xmemresetwritewatch)                       | XMemResetWriteWatch API 文档                                                                                |
| [XMemResumeWriteWatch](/reference/system/xmem/functions/xmemresumewritewatch)                     | 在写入跟踪被 PIX GPU 捕获挂起之后，通知 XMem 调用方已准备好恢复写入跟踪。                                                              |
| [XMemSetAllocationHooks](/reference/system/xmem/functions/xmemsetallocationhooks)                 | 供游戏用于注册内存分配挂钩。                                                                                            |
| [XMemSetAllocationHysteresis](/reference/system/xmem/functions/xmemsetallocationhysteresis)       | 设置给定堆的滞后量，向上舍入到内部分配边界（4 MB）。                                                                              |
| [XMemSetOption](/reference/system/xmem/functions/xmemsetoption)                                   | 设置 XMem 的配置项。                                                                                             |
| [XMemSetWin32HeapName](/reference/system/xmem/functions/xmemsetwin32heapname)                     | XMemSetWin32HeapName API 文档                                                                               |
| [XMemSetWin32HeapTrackingHooks](/reference/system/xmem/functions/xmemsetwin32heaptrackinghooks)   | 设置用于 Win32 堆的内存分配、重新分配和释放的跟踪回调函数。                                                                         |
| [XMemTransferMemory](/reference/system/xmem/functions/xmemtransfermemory)                         | 在分区之间转移内存。                                                                                                |
| [XMemVirtualAlloc](/reference/system/xmem/functions/xmemvirtualalloc)                             | 在调用进程的虚拟地址空间中预留、提交或更改一段页区域的状态。                                                                            |
| [XMemVirtualQuery](/reference/system/xmem/functions/xmemvirtualquery)                             | 检索有关调用进程虚拟地址空间中一段页范围的信息。                                                                                  |

## 结构

| 结构                                                                                           | 描述                     |
| -------------------------------------------------------------------------------------------- | ---------------------- |
| [WIN32\_HEAP\_STATISTICS](/reference/system/xmem/structs/win32_heap_statistics)              | 包含给定堆的统计信息。            |
| [XALLOC\_ATTRIBUTES](/reference/system/xmem/structs/xalloc_attributes)                       | 包含描述内存分配属性的值。          |
| [XMEM\_ALLOCATION\_HOOKS](/reference/system/xmem/structs/xmem_allocation_hooks)              | 表示游戏的内存分配和释放函数的挂钩。     |
| [XMEM\_BASIC\_INFORMATION](/reference/system/xmem/structs/xmem_basic_information)            | 包含有关进程虚拟地址空间中一段页范围的信息。 |
| [XMEM\_HEAP\_STATISTICS](/reference/system/xmem/structs/xmem_heap_statistics)                | 包含给定堆的统计信息。            |
| [XMEM\_OPTION](/reference/system/xmem/structs/xmem_option)                                   | 指定内存选项的类型和值。           |
| [XMEM\_PHYSICAL\_MEMORY\_LAYOUT](/reference/system/xmem/structs/xmem_physical_memory_layout) | 包含当前主机的物理内存布局的详细信息。    |
| [XMEM\_WORKING\_SET\_STATISTICS](/reference/system/xmem/structs/xmem_working_set_statistics) | 包含游戏进程中内存精确使用情况的详细信息。  |

## 枚举

| 枚举                                                                          | 描述                                                                                          |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| [XALLOC\_ALLOCATOR\_IDS](/reference/system/xmem/enums/xalloc_allocator_ids) | 定义内存分配例程使用的不同类型分配器的一组 ID 的范围。                                                               |
| [XMEM\_OPTIONS](/reference/system/xmem/enums/xmem_options)                  | XMEM\_OPTIONS 值用作 [XMEM\_OPTION](/reference/system/xmem/structs/xmem_option) 结构的 Option 参数。 |
| [XMEM\_TRANSFER\_TYPE](/reference/system/xmem/enums/xmem_transfer_type)     | 指示要将内存传输到何处和从何处传输。                                                                          |

## 宏

| 宏                                                                                       | 描述             |
| --------------------------------------------------------------------------------------- | -------------- |
| [XMEM\_SET\_ALLOCATION\_HOOKS](/reference/system/xmem/macros/xmem_set_allocation_hooks) | 供游戏用于注册内存分配挂钩。 |

## 概念性文档

* [XBOX One 内存系统](/build/console-features/memory/system-memory-overview)
* [分析内存分配](/build/console-features/memory/system-memory-diagnostics)
* [内存管理（面向 XBOX 游戏的 Microsoft Game Development Kit (GDK) 移植指南）](/build/console-features/porting-from-xbox-one-era/porting-guide-for-existing-era#MEMMGMT)

## 另请参阅

[系统 API 参考](/reference/system/gc-reference-system-toc)


## Related topics

- [XMEM_OPTIONS](/zh-CN/reference/system/xmem/enums/xmem_options.md)
- [XMEM_ALLOCATION_HOOKS](/zh-CN/reference/system/xmem/structs/xmem_allocation_hooks.md)
- [XMemIsToolsMemAvailable](/zh-CN/reference/system/xmem/functions/xmemistoolsmemavailable.md)
- [XMemVirtualQuery](/zh-CN/reference/system/xmem/functions/xmemvirtualquery.md)
- [XMemSetOption](/zh-CN/reference/system/xmem/functions/xmemsetoption.md)
