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

# PFMultiplayerSetMemoryCallbacks

> Reference for PFMultiplayerSetMemoryCallbacks, letting you install custom allocate and free callbacks used by the PlayFab Multiplayer C/C++ library.

Optionally configures the memory allocation and freeing callbacks the Multiplayer library should use.

## Syntax

```cpp theme={null}
HRESULT PFMultiplayerSetMemoryCallbacks(  
    PFMultiplayerAllocateMemoryCallback allocateMemoryCallback,  
    PFMultiplayerFreeMemoryCallback freeMemoryCallback  
)  
```

### Parameters

**`allocateMemoryCallback`**   [PFMultiplayerAllocateMemoryCallback](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/callbacks/pfmultiplayerallocatememorycallback)

A pointer to the custom allocation callback to use.

**`freeMemoryCallback`**   PFMultiplayerFreeMemoryCallback

A pointer to the custom freeing callback to use.

### Return value

Type: HRESULT

`S_OK` if the call succeeded or an error code otherwise. The human-readable form of the error code can be retrieved via [PFMultiplayerGetErrorMessage()](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayergeterrormessage).

## Remarks

This method allows the title to install custom memory allocation functions in order to service all requests by the Multiplayer library for new memory buffers instead of using its default allocation functions. <br /><br /> The `allocateMemoryCallback` and `freeMemoryCallback` parameters must both be non-null.   <br /><br /> To use this method, it must be called before any other Multiplayer method. This method cannot be called again for the lifetime of this process.

## Requirements

**Header:** PFMultiplayer.h

## See also

[PFMultiplayer members](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members)\
[PFMultiplayerAllocateMemoryCallback](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/callbacks/pfmultiplayerallocatememorycallback)\
[PFMultiplayerFreeMemoryCallback](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/callbacks/pfmultiplayerfreememorycallback)


## Related topics

- [PFMultiplayerFreeMemoryCallback](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/callbacks/pfmultiplayerfreememorycallback.md)
- [PFMultiplayerAllocateMemoryCallback](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/callbacks/pfmultiplayerallocatememorycallback.md)
- [PFMultiplayerInitialize](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/functions/pfmultiplayerinitialize.md)
- [PFMultiplayer C/C++ API overview - PFMultiplayer.h](/services/playfab/multiplayer/lobby/playfabmultiplayerreference-cpp/pfmultiplayer/pfmultiplayer_members.md)
- [PartyManager::SetMemoryCallbacks](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setmemorycallbacks.md)
