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

# PartyAllocateMemoryCallback

> A callback invoked every time the Party Library dynamically allocates a new memory buffer.

A callback invoked every time the Party Library dynamically allocates a new memory buffer.

## Syntax

```cpp theme={null}
typedef
void* (*PartyAllocateMemoryCallback)(  
    size_t size,  
    uint32_t memoryTypeId  
)  
```

### Parameters

**`size`**   size\_t

The size of the allocation to be made. This value will never be zero.

**`memoryTypeId`**   uint32\_t

An opaque identifier representing the Party library internal category of memory being allocated. This value should be ignored.

### Return value

Type: void\*

A pointer to an allocated block of memory of the specified size, or nullptr if the allocation failed.

## Remarks

This callback is optionally installed using the [PartyManager::SetMemoryCallbacks()](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setmemorycallbacks) method. <br /><br /> The callback must allocate and return a pointer to a contiguous block of memory of the specified size that remains valid until the title's corresponding [PartyFreeMemoryCallback](/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback) is invoked to release it. If this isn't possible, the callback must return nullptr to fail the allocation. Memory allocation failures are sometimes considered benign but usually cause current Party library operations to fail.   <br /><br /> Every non-nullptr returned by this method is then passed to the corresponding [PartyFreeMemoryCallback](/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback) once the memory is no longer needed.

## Requirements

**Header:** Party.h

## See also

[Party members](/services/playfab/multiplayer/networking/reference/party_members)\
[PartyFreeMemoryCallback](/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback)\
[PartyManager::SetMemoryCallbacks](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setmemorycallbacks)\
[PartyManager::GetMemoryCallbacks](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_getmemorycallbacks)


## Related topics

- [PartyManager::SetMemoryCallbacks](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_setmemorycallbacks.md)
- [PartyFreeMemoryCallback](/services/playfab/multiplayer/networking/reference/callbacks/partyfreememorycallback.md)
- [PartyManager::GetMemoryCallbacks](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_getmemorycallbacks.md)
- [PartyXblManager::SetMemoryCallbacks](/services/playfab/multiplayer/networking/xblreference/classes/PartyXblManager/methods/partyxblmanager_setmemorycallbacks.md)
- [PartyXblManager::GetMemoryCallbacks](/services/playfab/multiplayer/networking/xblreference/classes/PartyXblManager/methods/partyxblmanager_getmemorycallbacks.md)
