Wwise SDK 2024.1.0
|
It can be challenging to trim down memory usage to fit your required limit. Here are a few tips to help reduce memory usage:
Object memory usage is directly impacted by the number of sounds and events loaded in-memory and the amount of game objects. It contains all the properties of the objects in your project necessary to implement the behaviors of the sound design. It also contains all the game objects and their related information (game syncs values, position, orientation, and so on). The more banks are loaded, the more memory needs to be allocated. The size needed depends only on the number of sounds that can possibly be played in one scenario, level, map, game area, or the like. There are practices that can help reduce these allocations:
The memory in the Processing category is used to play sounds. It contains buffers to decompress, apply effects, and mix the audio sources. It is directly influenced by the number of sounds playing at the same time. It is also influenced by the number and type of effects that are used at the same time. To trim this down, you need to ask yourself how many sounds you want to hear at the same time. Some games will rarely have a scenario where more than 10 sounds are heard, others will have hundreds. You need to consider your worst case.
As a guideline, we have done some profiling on some games (on Xbox One) and had the following numbers:
To reduce the memory used for processing, you need to reduce the number of simultaneous voices. This can be done using:
Note: You can set limits on busses as well. |
Note: You can change the volume threshold programmatically at run-time. You may use this in game locations that are more process-heavy in order to send more voices to their "under volume threshold" state. |
The amount of memory taken by SoundBanks is mostly dictated by the sound data in it. Controlling the amount of memory used by your media can be done through:
Wwise uses an internal pool of memory to manage some temporary allocations that persist for less than one audio-render tick, which are represented in the Advanced Profiler's Memory tab as "Temp Alloc". These temporary allocations exist for a specific amount of time, have very little overhead, are handled internally by the sound engine, and cannot be forwarded to developer-provided memory allocation hooks. Instead, the only allocations in this regard that are observed by the Advanced Profiler and memory allocation hooks are the larger memory blocks that the temporary allocations are made from. Therefore, it might be desirable to manually tune the management of "Temp Alloc" memory blocks, in order to better optimize memory usage in your game.
During AK::MemoryMgr::Init
, AkMemSettings::tempAllocSettings
controls the behavior of the memory blocks for each Temp Alloc category. Notably, this includes configuring the size of the memory blocks, the minimum number of blocks that the system keeps allocated at all times, and how many blocks have to be unused for a tick before the system starts freeing memory. You can use AK::TempAlloc::GetStats()
to see how much memory the Temp Alloc system uses in your game at runtime, and better fine tune configuration of the system.
The following are some suggestions depending on your game's requirements, or other behavior observed during profiling:
AK::TempAlloc::InitSettings::uMinimumBlockSize
to a lower value than the default, so that it better matches the memory usage of your game's needs at any given time.AK::TempAlloc::Stats::uPeakMemUsed
to view the Temp Alloc system's peak memory usage, and then ensure that the AK::TempAlloc::InitSettings::uMinimumBlockCount
is set to a high enough value so that all of the blocks you might use are allocated when the sound engine is initialized, and never freed afterward.AK::TempAlloc::InitSettings::uMaximumUnusedBlocks
to a high value to ensure that the system can allocate new blocks, but not free them, even during periods of low memory load.AK::TempAlloc::InitSettings::uMinimumBlockSize
so that using more workers does not cause a significant increase in used memory in your game.Some debugging options are available in AK::TempAlloc::InitSettings
. In the Debug and Profile configuration of the sound engine, AK::TempAlloc::InitSettings::bDebugDetailedStats
and AK::TempAlloc::InitSettings::bDebugEnableSentinels
are enabled by default in order to improve tracking of usage statistics, and to provide some easy detection of buffer overruns. Disable these options when the highest performance, or most accurate profiling data, is required for your application. Support for these options is removed entirely in the Release configuration of the sound engine.
Wwise has a system called the "Bookmark Allocator" (similar to "Temp Alloc") for handling short-lived memory allocations that exist only for a single function or code block. This allows Wwise to perform temporary memory allocations as if they were on a stack, but instead of relying on the memory allocated for the thread's stack being sufficiently large to handle all possible scenarios, the Bookmark Allocator uses normal memory allocations to provide the necessary resources.
AkMemSettings::bookmarkAllocSettings
is available to control the behavior of memory blocks for the "Bookmark Allocator" memory category for allocating and freeing the underlying blocks of memory. Debug settings are available as well to detect buffer overruns, and clearing allocated memory to a deterministic invalid value before and after use. You can use AK::BookmarkAlloc::GetStats for information on how the "Bookmark Allocator" is being used.
The following are some suggestions depending on your game's requirements, or other behavior observed during profiling:
AK::BookmarkAlloc::Stats::uRecentBlocksFetched
might result in excessive thread contention in multi-threaded scenarios. It might therefore be desirable to increase AK::BookmarkAlloc::InitSettings::uMinimumBlockSize
so that the blocks used by the "Bookmark Allocator" are larger, and do not need to temporarily request new blocks as often. You can use AK::BookmarkAlloc::Stats::uRecentPeakMemUsed
to help determine what the minimum block size should be.AK::BookmarkAlloc::Stats::uPeakMemUsed
in order to reduce the size of AK::BookmarkAlloc::InitSettings::uMinimumBlockSize
if you find that you are not using all of the memory being provided.AK::BookmarkAlloc::InitSettings::uMaximumUnusedBlocks
so that the memory use is more consistent over time. Alternatively you can increase AK::BookmarkAlloc::InitSettings::uMinimumBlockSize
so that the first block acquired by a job is all that is required. Questions? Problems? Need more info? Contact us, and we can help!
Visit our Support pageRegister your project and we'll help you get started with no strings attached!
Get started with Wwise