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

# ApuCreateHeap

> ApuCreateHeap

# ApuCreateHeap

Creates the APU heap.

## Syntax

```cpp theme={null}
HRESULT ApuCreateHeap(  
         UINT32 cachedSizeInBytes,  
         UINT32 nonCachedSizeInBytes = 0  
)  
```

### Parameters

*cachedSizeInBytes*   \_In\_\
Type: UINT32

Size of a cached memory allocation, in bytes.

*nonCachedSizeInBytes*   \_In\_opt\_\
Type: UINT32

Size of a non-cached allocation, in bytes. If 0, use the default allocation of \~1 MB.

### Return value

Type: HRESULT

In addition to other error codes, this method can return the following values:

| Return code                      | Description                     |
| :------------------------------- | :------------------------------ |
| S\_OK                            | Success                         |
| E\_INVALIDARG                    | Invalid argument (size == 0)    |
| E\_OUTOFMEMORY                   | Memory allocation failure       |
| APU\_E\_HEAP\_ALREADY\_ALLOCATED | Heap has already been allocated |

## Remarks

Only a single APU heap can be created; it persists for the lifetime of the process. The heap is released only when the process terminates.

To ensure that a heap is allocated to your specific requirements, call this method before any other ACP HAL and APU method.

If any [ACP HAL](/reference/audio/acphal/acphal_members) (AcpHal.h) or [APU](/reference/audio/apu/apu_members) methods are called before this method, a cached heap of 64 MB and a non-cached heap of \~1 MB are allocated; subsequent calls to this method will fail with `APU_E_HEAP_ALREADY_ALLOCATED`.

Cached memory is used for all Waves assets and command and message queues. Non-cached memory is used for SHAPE contexts and notifications.

## Requirements

**Header:** apu.h

**Library:** acphal.lib

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

## Conceptual documentation

* [ACP overview](/build/console-features/audio/overviews/acp-overview)

## See also

[APU](/reference/audio/apu/apu_members)


## Related topics

- [ApuHeapState](/reference/audio/apu/structs/apuheapstate.md)
- [ApuHeapGetState](/reference/audio/apu/functions/apuheapgetstate.md)
- [APU (Audio Processing Unit)](/reference/audio/apu/apu_members.md)
- [ACP overview](/build/console-features/audio/overviews/acp-overview.md)
- [IAcpHal::SubmitCommand](/reference/audio/acphal/interfaces/IAcpHal/methods/iacphal_submitcommand.md)
