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

可用來在記憶體分析工具中識別記憶體配置群組的識別碼。例如，如果您針對圖形、音訊和物理等項目使用不同的堆積，則可以為每個類別指派不同的 **allocatorID**，以便在 PIX 中檢視記憶體擷取時輕鬆識別。

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

已配置之記憶體的起始位址。

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

已配置之記憶體的大小 (以位元組為單位)。

*metadata*   <br />類型：UINT64

64 位元不帶正負號的整數，可用來以其他資料標記配置。這些額外資料會顯示在 PIX 的 **UserData** 資料行中。例如，您可以使用這些額外資料來識別遊戲中儲存在指定記憶體位置之物件的類型。

### 傳回值

類型：void

## 備註

PIX 記憶體追蹤事件會提供 PIX 所需的資料，以便在記憶體分析擷取中顯示從遊戲自訂記憶體配置器內進行之所有記憶體配置和釋放的相關資訊。提供此資料後，PIX 會為您的自訂配置器顯示與 **VirtualAlloc**/**VirtualFree** 和 **HeapAlloc**/**HeapFree** 呼叫相同的所有資料。

如果同時發生許多事件，或系統處於高負載狀態，記憶體事件可能會被 Event Tracing for Windows (ETW) 遺失。事件遺失會導致資料分析不完整。PIX 記憶體擷取 UI 會顯示警告，指出發生事件遺失。

可以使用多個 [PIXRecordMemoryFreeEvent](/zh-TW/reference/tools/pix3/functions/pixrecordmemoryfreeevent) 呼叫，來追蹤從單一配置逐步釋放的記憶體。

如需自訂配置和釋放的資料如何在記憶體擷取中顯示的相關資訊，請參閱 [PIX 自訂記憶體配置器 (NDA 主題)](/zh-TW/tools/tools-console/pix/pix-custom-memory-allocators)。

## 需求

**標頭：** pixmemory.h

**程式庫：** pixevt.lib

**支援的平台：** XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [ATG 系統參與檢查清單](/zh-TW/build/atg-engagement/atg-systems-engagement)

## 另請參閱

[PIX (NDA 主題)](/zh-TW/tools/tools-console/pix/pix)

[PIX 自訂記憶體配置器 (NDA 主題)](/zh-TW/tools/tools-console/pix/pix-custom-memory-allocators)

[PIX API 參考](/zh-TW/reference/tools/pix3/pix3_members)

[PIXRecordMemoryFreeEvent](/zh-TW/reference/tools/pix3/functions/pixrecordmemoryfreeevent)


## Related topics

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