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

# game_chat_free_memory_callback

> game_chat_free_memory_callback

# game\_chat\_free\_memory\_callback

表示每次先前分配的内存缓冲区不再被 Game Chat 2 库需要并可以释放时调用的回调。

<a id="syntaxSection" />

## 语法

```cpp theme={null}
typedef  
void  
(game_chat_callback * game_chat_free_memory_callback)(  
    _In_ _Post_invalid_ void * pointer,  
    _In_ uint32_t memoryTypeId  
    );  
```

<a id="parametersSection" />

### 参数

*pointer*   \_In\_ \_Post\_invalid\_\
类型:void\*

指向先前分配的内存缓冲区的指针。此值永远不会是空指针。

*memoryTypeId*   \_In\_\
类型:uint32\_t

表示要释放内存的 Game Chat 2 内部类别的不透明标识符。

<a id="remarksSection" />

## 备注

此函数表示一个自定义回调,如果可用,每次先前分配的内存缓冲区不再被 Game Chat 2 库需要并可以释放时都会被调用。此回调是可选的,可通过调用 [chat\_manager::set\_memory\_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks) 方法进行安装。如果未安装自定义回调,Game Chat 2 会使用其自己的默认函数分配和释放内存。您可以使用 [chat\_manager::get\_memory\_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks) 方法来确定应用是使用默认函数还是自定义函数分配和释放内存。

<Note>如果您希望使用自定义函数分配和释放内存,则必须实现一组对应的 [game\_chat\_allocate\_memory\_callback](/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback) 和 `game_chat_free_memory_callback` 函数。您不能混合使用自定义函数和默认函数来分配和释放内存。</Note>

每当 Game Chat 2 库完成对应用先前 [game\_chat\_allocate\_memory\_callback](/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback) 所返回的内存缓冲区的使用时,就会调用此回调,指示应用可以释放该内存缓冲区。

<a id="requirementsSection" />

## 需求

**头文件:** GameChat2.h

**支持的平台:** Windows、XBOX One 家族主机以及 XBOX Series 主机

<a id="seealsoSection" />

## 另请参阅

[Game Chat 2 简介](/services/xbox-services/multiplayer/chat/game-chat2/game-chat-2-intro)\
[chat\_manager](/reference/chat/gamechat2/classes/chat_manager/chat_manager)\
[GameChat2 members](/reference/chat/gamechat2/gamechat2_members)


## Related topics

- [chat_manager::set_memory_callbacks](/zh-CN/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks.md)
- [chat_manager::get_memory_callbacks](/zh-CN/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks.md)
- [game_chat_allocate_memory_callback](/zh-CN/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback.md)
- [GameChat2 members](/zh-CN/reference/chat/gamechat2/gamechat2_members.md)
- [PartyFreeMemoryCallback](/zh-CN/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback.md)
