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

# PIXRecordMemoryAllocationEvent

> PIXRecordMemoryAllocationEvent

# PIXRecordMemoryAllocationEvent

记录一个内存分配事件。

## 语法

```cpp theme={null}
void PIXRecordMemoryAllocationEvent(  
         USHORT allocatorId,  
         void* baseAddress,  
         size_t size,  
         UINT64 metadata  
)  
```

### 参数

*allocatorId*   <br />类型：USHORT

一个 ID，你可以使用它在内存分析器中标识内存分配组。例如，如果你有针对图形、音频和物理等不同事项的不同堆，则可以为这些类别中的每一个分配不同的 **allocatorID**，以便在 PIX 中查看内存捕获时易于识别。

*baseAddress*   <br />类型：void\*

已分配内存的起始地址。

*size*   <br />类型：size\_t

已分配内存的字节大小。

*metadata*   <br />类型：UINT64

一个 64 位无符号整数，你可以使用它以额外数据来标记分配。这些额外数据在 PIX 中显示在 **UserData** 列中。例如，你可以使用这些额外数据来识别游戏中在给定内存位置存储的对象类型。

### 返回值

类型：void

## 备注

PIX 内存跟踪事件提供 PIX 所需的数据，以便在内存分析捕获中显示有关游戏自定义内存分配器内所有内存分配和释放的信息。通过提供这些数据，PIX 将为你的自定义分配器显示与 **VirtualAlloc**/**VirtualFree** 和 **HeapAlloc**/**HeapFree** 调用相同的所有数据。

如果同时发生许多事件或系统处于繁重负载下，则内存事件可能会被 Windows 事件跟踪 (ETW) 丢失。事件丢失将导致数据分析不完整。PIX 内存捕获 UI 将显示指示事件丢失的警告。

可以使用多个 [PIXRecordMemoryFreeEvent](/reference/tools/pix3/functions/pixrecordmemoryfreeevent) 调用来跟踪从单个分配中逐步释放的内存。

有关自定义分配和释放数据如何在内存捕获中显示的信息，请参阅 [PIX 自定义内存分配器（NDA 主题）](/tools/tools-console/pix/pix-custom-memory-allocators)。

## 要求

**头文件：** pixmemory.h

**库：** pixevt.lib

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

## 概念文档

* [ATG 系统合作清单](/build/atg-engagement/atg-systems-engagement)

## 另请参阅

[PIX（NDA 主题）](/tools/tools-console/pix/pix)

[PIX 自定义内存分配器（NDA 主题）](/tools/tools-console/pix/pix-custom-memory-allocators)

[PIX API 参考](/reference/tools/pix3/pix3_members)

[PIXRecordMemoryFreeEvent](/reference/tools/pix3/functions/pixrecordmemoryfreeevent)


## Related topics

- [PIXRecordMemoryFreeEvent](/zh-CN/reference/tools/pix3/functions/pixrecordmemoryfreeevent.md)
- [PIX3](/zh-CN/reference/tools/pix3/pix3_members.md)
- [DSTORAGE_ERROR_RECORD](/zh-CN/reference/system/dstorage/structs/dstorage_error_record.md)
- [XMEM_ALLOCATION_HOOKS](/zh-CN/reference/system/xmem/structs/xmem_allocation_hooks.md)
- [IDStorageQueueX::RetrieveErrorRecord](/zh-CN/reference/system/dstorage/interfaces/IDStorageQueueX/methods/idstoragequeuex_retrieveerrorrecord.md)
