Table des matières
-
Lessons
Although frequent monitoring memory usage is generally good practice, many game productions also have specific CPU and memory budgets reserved for each department. The audio department might have a budget of, for example, 100MB from all sound engine memory, which would require a lot of effort to ensure that you don’t exceed the budget. However, because games are interactive, there might be cases in which memory exceeds this budget. For instance, your game might use procedurally generated assets in which loading too much is unavoidable by game design. Therefore, to be sure that your memory usage does not exceed your team's memory budget, you can set a limit.
In a real game production, it's best to start by controlling your soundscape with features like playback limits, which also allows you to decide which sounds should have more leeway than others. The Memory Allocation Size Limit is meant to be used as a last resort. |
-
In the WAG Unity project, go to Edit > Project Settings > Wwise Initialization and scroll down to Memory Allocation Size Limit. The Memory Allocation Size Limit restricts the amount of memory Wwise can use in total. Unlike other game engines, Wwise does not crash if the memory limit is exceeded. Instead, an error appears in the Profiler, and the sounds that are already loaded into memory remain accessible. Let's set a limit and see what happens when you reach the limit.
-
In the Memory Allocation Size Limit, set a limit of 35 000 000.
The property is defined in bytes, so 35 000 000 is a limit of 35 000 KB or 35MB.
-
Connect to the remote session (in Profile Only mode) and press Play in Unity.
The Memory Allocation Size limit is displayed above the Memory tab categories in Wwise. Why does the limit display 33.4MB and not 35MB as specified in the Wwise Initialization settings? Memory in Wwise is displayed in a different unit system (MiB, but displayed in the user interface as MB). Therefore, to set an actual 35MB limit in Wwise, you need to convert it to MiB before you set it in the Wwise Initialization settings. You can use a formula like DesiredLimit * 1024 * 1024 = ActualLimitNumber. Therefore, to set the limit to 35MB in Wwise, you need to set the Memory Allocation Size limit to the product of 35 * 1024 * 1024, or 36 700 160.
-
Set the Memory Allocation Size Limit to 36 700 160.
-
Open the menu and teleport to the Dungeon.
-
Exit play mode, and open the Wwise Profiler.
You should now see multiple errors, at least one of which states the following:
Memory allocation failed: ______ bytes in category '______' - media?: no - device?: no - currently allocated ______ / 35000000 bytes
When teleporting to the dungeon, the Memory Allocation Size Limit is exceeded so the Profiler tells you which memory category caused it, and more. Furthermore, notice how the game did not freeze or crash. The soundscape might lack a few aspects that could not be loaded, but it continues to play the sounds that were already loaded into memory. The game keeps running, and a safety net on memory usage is maintained.