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

# XblMemFreeFunction

> Defines a callback that frees memory that was allocated for the XBOX Services API (XSAPI).

# XblMemFreeFunction

A callback that the XBOX Services API (XSAPI) invokes each time it no longer needs a previously allocated memory buffer.

## Syntax

```cpp theme={null}
typedef void (STDAPIVCALLTYPE* XblMemFreeFunction)(  
         _In_ _Post_invalid_ void* pointer,  
         _In_ HCMemoryType memoryType  
);  
```

### Parameters

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

The pointer to the memory buffer that was previously allocated by the corresponding [XblMemAllocFunction](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemallocfunction.md) callback. This value is never a null pointer. The pointer is invalid after the callback returns.

*memoryType*   \_In\_\
Type: HCMemoryType

An opaque identifier that represents the internal category of memory that was allocated.

### Return value

Type: void

## Remarks

XSAPI invokes this callback when it finishes using a memory buffer that the app's `XblMemAllocFunction` callback returned, so that the app can free the buffer.

This callback is optional. Install it, together with an `XblMemAllocFunction` callback, by calling [XblMemSetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemsetfunctions.md) before you call [XblInitialize](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblinitialize.md). Both callbacks must be set together. `XblMemSetFunctions` also passes the callbacks to libHttpClient. If libHttpClient is already initialized, it keeps its existing memory hooks.

If you install custom memory callbacks, wait for [XblCleanupAsync](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblcleanupasync.md) to complete before you shut down your memory manager. If your app dispatches XSAPI work concurrently, make sure that any allocator state shared by the callbacks is safe for concurrent use.

For an example, see [XblMemAllocFunction](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemallocfunction.md).

## Argument of

[XblMemSetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemsetfunctions.md)\
[XblMemGetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemgetfunctions.md)

## Requirements

**Header:** xbox\_live\_global\_c.h

**Library:** Microsoft.Xbox.Services.142.C.lib or Microsoft.Xbox.Services.143.C.lib

## See also

[xbox\_live\_global\_c](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/xbox_live_global_c_members.md)\
[XblMemAllocFunction](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemallocfunction.md)


## Related topics

- [XblMemAllocFunction](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemallocfunction.md)
- [XblMemGetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemgetfunctions.md)
- [XblMemSetFunctions](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/functions/xblmemsetfunctions.md)
- [xbox_live_global_c (contents)](https://docs.xbox.com/reference/live/xsapi-c/xbox_live_global_c/xbox_live_global_c_members.md)
- [HCMemFreeFunction](https://docs.xbox.com/reference/live/httpclient/httpclient/functions/hcmemfreefunction.md)
