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

Represents a callback invoked every time a previously-allocated memory buffer is no longer needed by the Game Chat 2 library and can be freed.

<a id="syntaxSection" />

## Syntax

```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" />

### Parameters

*pointer*   \_In\_ \_Post\_invalid\_\
Type: void\*

The pointer to the memory buffer previously allocated. This value will never be a null pointer.

*memoryTypeId*   \_In\_\
Type: uint32\_t

An opaque identifier that represents the Game Chat 2 internal category for the memory being freed.

<a id="remarksSection" />

## Remarks

This function represents a custom callback that, if available, is invoked every time a previously-allocated memory buffer is no longer needed by the Game Chat 2 library and can be freed. This callback is optional, and can be installed by calling the [chat\_manager::set\_memory\_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks) method. If custom callbacks are not installed, Game Chat 2 uses its own default functions to allocate and free memory. You can use the [chat\_manager::get\_memory\_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks) method to determine whether your app is using default or custom functions to allocate and free memory.

<Note>If you want to use custom functions to allocate and free memory, you must implement a corresponding set of [game\_chat\_allocate\_memory\_callback](/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback) and `game_chat_free_memory_callback` functions. You cannot mix custom and default functions to allocate and free memory.</Note>

This callback is invoked whenever the Game Chat 2 library has finished using a memory buffer previously returned by the app's corresponding [game\_chat\_allocate\_memory\_callback](/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback), and indicates that the app can free the memory buffer.

<a id="requirementsSection" />

## Requirements

**Header:** GameChat2.h

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

<a id="seealsoSection" />

## See also

[Intro to 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::get_memory_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_get_memory_callbacks.md)
- [chat_manager::set_memory_callbacks](/reference/chat/gamechat2/classes/chat_manager/methods/chat_manager_set_memory_callbacks.md)
- [game_chat_allocate_memory_callback](/reference/chat/gamechat2/functions/game_chat_allocate_memory_callback.md)
- [GameChat2 members](/reference/chat/gamechat2/gamechat2_members.md)
- [PartyFreeMemoryCallback](/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback.md)
