메모리 풀 최적화

Wwise has two memory pools:

  • Default: A general-usage pool for high-level sound structures. When loading banks, this is where the non-WAV data ends up. Game objects and their related positioning and RTPC data structures are also stored here. It also contains the command queue where posted events are stored before being processed by the audio thread. Finally, it contains a small amount of high-level per-voice playback data.
  • Lower engine: The main audio processing pipeline pool, essentially empty when nothing is playing. Here are allocated all the intermediate processing buffers for things such as decompression, format-conversion, pitch-shifting, effect processing, and mixing.

자신의 메모리 풀에 적합한 크기 정하기

The default size of the internal memory pools of the sound engine are very large only to ensure that anyone who tries the sound engine for the first time has enough resources to run their worst-case scenario. The default size for each pool is:

참고: If you use the sample code to integrate the streaming manager, 8 MB are also allocated for the streaming buffers (Stream I/O).

기본 메모리 풀의 크기는 궁극적으로 제작 중인 게임의 유형에 따라 다릅니다. For example, if your game has gigabytes of audio assets but rarely plays more than four or five sounds at a time, with no or few effects, then the memory requirements of the default memory pool may be larger, but the requirements of the lower engine memory pool may be smaller. If, on the other hand, your game has few sounds but plays them all simultaneously with lots of reverb, echo, and other environmental effects, like in a first-person shooter, then the memory requirements of the default memory pool may be smaller, but the requirements of the lower engine memory pool may be larger. 엔진 내부 메모리 풀의 크기는 궁극적으로 사운드 엔진을 사용하는 법에 따라 달라집니다. If your game will play a lot of voices simultaneously (including virtual voices) and will be processing a large number of effects, then you will need more memory in this pool.

Setting the Size of Your Memory Pools

On PC, with no banks loaded or sounds playing, the amount of memory used should be around 150 KB. You can see the exact amount in Wwise by switching to the Profiler layout and looking at the Total Used Memory value in the Performance Monitor. This value will go up with the number of assets loaded, voices playing, game object positions, and so on.

The required size of your memory pools will depend on a number of different factors, including the quality of your audio, the number of sounds loaded, the number of voices playing simultaneously, the complexity of your sound structures, the encoding method chosen, the type and number of effects that require processing, the number of 3D positioned sounds, switches, and so on.

필요한 메모리의 양을 알 수 있는 유일한 방법은 다음 과정을 거치는 것입니다.

  1. Assign an arbitrary amount of memory to the pools. 가능하다면 기본 메모리 크기를 사용하는 것으로 시작하세요.
  2. Connect Wwise to your game.
  3. Run a busy game scenario with the Profile version of the sound engine.
  4. Look at the Memory tab of the Advanced Profiler. The Peak Used column should give you a good indication of what the pool sizes should be.

대부분 각 풀의 최적의 크기는 피크 메모리 사용 값보다 15-20만큼 더 많은 수준입니다.

Debug-only allocations are made in the Communications, Monitor, and Monitor Queue memory pools, which are not created in the Release version. 이 풀들의 크기를 빼면 출시 버전에 적합한 메모리 사용량을 예측할 수 있습니다.

참고: You can also explore sound engine memory usage in the Memory tab by capturing profile information from Wwise itself without connecting to a game.

What Size Should I Use to Get Started?

대부분의 경우 기본 메모리 풀 크기(풀마다 16 MB)를 사용하여 테스트를 시작하는 것이 가장 좋습니다. 이렇게 큰 풀 크기를 사용해서 먼저 실제 메모리 사용량이 얼마인지 찾아낸 다음 그에 따라 풀의 크기를 알맞게 줄이면 됩니다. If you are more restricted in the amount of memory you can assign to these pools (16 MB is too much), you can start by using the following values:

  • Default memory pool: 2 MB
  • Lower engine memory pool: 2 MB
  • Streaming management: 2 MB

2 MB per pool should be enough to cover most, if not all, of your scenarios. 스트리밍 버퍼 크기는 스트리밍할 사운드의 개수, 사운드의 음질, 스트리밍 사운드의 안전 타임라인(safety timeline) 등에 따라 결정됩니다. The default value of 8 MB would generally be seen as a waste of memory for most games, but again it is best to start out large and trim down as your memory usage becomes clearer. For more information on streaming buffer memory, refer to Audiokinetic Stream Manager Initialization Settings.

Memory Pool Sizes and Platforms

각 플랫폼의 풀 크기를 설정할 때, 메모리 풀의 크기는 사용하는 플랫폼보다 오디오 콘텐츠와 사용량에 더 의존적이라는 것을 이해하는 것이 굉장히 중요합니다. This means that you can use the same pool sizes to start with and then tailor them to the particular platform using the memory readings in the Advanced Profiler.

What is the optimal size to set for each memory pool? This depends on many things, including:

  • File format used
  • Maximum number of sounds that can be played at one time
  • Number of sounds pre-loaded using banks
  • Effects used
  • Rate of Events/RTPC/position updates per second
  • Speaker setup selected (especially on PC )
  • And other related considerations

Choosing Worst Case Scenarios for Testing

최악의 상황은 각 메모리 풀마다 다를 수 있습니다. For example, playing sixty-four sounds at once greatly increases usage of the lower engine pool while only slightly increasing usage of the upper one. On the other hand, loading twenty banks all at once increases upper engine memory usage without affecting lower memory pool usage. Therefore, we recommend that you don’t use just one worst case scenario for all your tests, because other situations may use memory differently.

One particular situation to test occurs when SoundBanks are loaded and unloaded between levels. This is because it causes a peak in the upper memory pool. For example, if the banks from Level 1 and Level 2 of a game can both be loaded at the same time for a brief interval, this peaking may occur.

주의: When performing tests to check peak memory usage for PC, you must ensure that the speaker setup configuration of the PC running the game is set to 5.1 or better. This is necessary because the sound engine performs some optimizations when the speaker setup is stereo, and therefore may use less memory than in 5.1.

Running out of Memory

The sound engine reacts differently to "out of memory" conditions depending on when the condition occurs. For example, here is what happens when memory is missing in the following scenarios:

  • Sound engine initialization: The initialization fails.
  • Loading a bank: The bank load fails.
  • Starting a transition for a parameter, such as volume: The transition is skipped and the parameter jumps directly to the target value without transition.
  • Playing a sound: Either the play fails or another playback with lower priority is stopped to free memory for the new one.

Detecting Memory Problems

Wwise Profiler를 사용하면 게임에서 메모리 할당이 실패할 때마다 Capture Log에 경고 알림이 뜹니다. 이 알림 목록을 확인하여 게임 플레이 도중 어떤 메모리 풀에 메모리가 부족한지 찾아낼 수 있습니다.

Causes of High Memory Usage

다음 아이템은 메모리 사용량을 높일 수 있습니다.

  • Loading banks increases Default memory pool usage. 각 뱅크가 사용하는 메모리의 양이 다르다는 점을 주의하세요. Memory used by a bank in the Default memory pool does not depend on the physical size of the bank but on the number of sounds and events that it contains.
  • Some effects, including reverb and delay, consume a certain amount of memory when playing.
  • Playing multiple sounds at once drastically increases the amount of memory used in the Lower Engine Default pool.
  • Sending multiple actions in a short amount of time increases the memory usage of the Default pool.
  • Registering game objects, setting "per object" parameters, and setting object positions all use a small amount of memory in the Default pool. However, be aware that unused game objects must be unregistered to free up this memory. 그렇지 않으면 메모리 사용량이 계속 증가합니다.

More details are available in the following sections:

Defining a Memory Threshold

When initializing the sound engine, you have the option to define a memory threshold for one or more of the sound engine's memory pools.

You can define a threshold for a memory pool by modifying the values in the initialization parameters of the sound engine: AkInitSettings::fDefaultPoolRatioThreshold and AkPlatformInitSettings::fLEngineDefaultPoolRatioThreshold

By default, the memory threshold is disabled, by using a default value of 1 (or 100%). 이 값을 0에서 1 사이의 값으로 설정하여 한계점을 활성화할 수 있습니다.

메모리 한계점이 비활성화되면 메모리 할당은 정상적으로 실행됩니다. 메모리 한계점이 활성화되면 엔진이 주기적으로 메모리의 백분율이 지정된 한계점보다 낮은지를 확인합니다. 한계점을 초과할 경우 시스템이 우선 순위가 가장 낮은 사운드부터 제거를 시작합니다.

한계점이 사용되지 않는 상황에서 엔진은 사운드의 우선 순위를 따르지만, 메모리가 부족할 경우 우선 순위가 높은 사운드마저 재생할 메모리가 부족해서 재생되지 않을 수 있습니다. 메모리 한계점이 사용되면 우선 순위가 낮은 사운드가 제거되어 우선 순위가 높은 사운드가 유지되도록 공간을 확보합니다.

In general, you will define a threshold for the AkPlatformInitSettings::fLEngineDefaultPoolRatioThreshold parameter. Setting a threshold on the AkInitSettings::fDefaultPoolRatioThreshold parameter could result in unexpected behaviors because it is also used to load banks.