> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PFMemFreeFunction

> Callback that PlayFab calls to free a non-null memory buffer that the title's PFMemAllocFunction callback allocated, after PlayFab no longer needs it.

A callback that PlayFab calls every time a memory buffer that it allocated is no longer needed and can be freed.

## Syntax

```cpp theme={null}
void STDAPIVCALLTYPE PFMemFreeFunction(
    void* pointer,
    uint32_t memoryTypeId
);
```

### Parameters

**`pointer`**   `_In_ _Post_invalid_` void\*

The pointer to the memory buffer that your [PFMemAllocFunction](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/functions/pfmemallocfunction.md) callback allocated. This value is never `nullptr`. The pointer isn't valid after the callback returns.

**`memoryTypeId`**   `_In_` uint32\_t

An opaque identifier for the internal category of memory being freed. Ignore this value.

### Return value

Type: void

## Remarks

To install this callback, set it in the `free` member of a [PFMemoryHooks](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/structs/pfmemoryhooks.md) structure and pass the structure to [PFMemSetFunctions](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/functions/pfmemsetfunctions.md) before you call [PFInitialize](https://docs.xbox.com/services/playfab/api-references/c/pfcore/functions/pfinitialize.md). Set the `alloc` member to a matching PFMemAllocFunction callback at the same time. PFMemSetFunctions returns `E_INVALIDARG` if only one of the two members is set.

PlayFab calls this callback when it has finished using a memory buffer that your PFMemAllocFunction callback returned, so that you can free the buffer. PlayFab doesn't call this callback with `nullptr`.

If libHttpClient isn't initialized yet when you call PFMemSetFunctions, PlayFab also installs hooks that route libHttpClient's frees through this callback.

PlayFab can call this callback from different threads, so make it thread-safe.

## Requirements

**Header:** PFPlatform.h

**Library:** PlayFabCore.lib

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

## See also

[PFPlatform members](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/pfplatform_members.md)

[PFMemoryHooks](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/structs/pfmemoryhooks.md)

[PFMemAllocFunction](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/functions/pfmemallocfunction.md)


## Related topics

- [PFMemAllocFunction](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/functions/pfmemallocfunction.md)
- [PFMemoryHooks](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/structs/pfmemoryhooks.md)
- [Services C API overview - PFPlatform.h](https://docs.xbox.com/services/playfab/api-references/c/pfplatform/pfplatform_members.md)
- [HCMemFreeFunction](https://docs.xbox.com/reference/live/httpclient/httpclient/functions/hcmemfreefunction.md)
- [XblMemFreeFunction](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemfreefunction.md)
