menu
版本
2023.1.14.8770
2024.1.6.8842
2023.1.14.8770
2025.1.0.8897
2022.1.19.8584
2021.1.14.8108
2019.2.15.7667
2019.1.11.7296
2018.1.11.6987
2017.2.10.6745
2017.1.9.6501
2016.2.6.6153
2015.1.9.5624
2024.1.6.8842
2023.1.14.8770
2025.1.0.8897
2022.1.19.8584
2021.1.14.8108
2019.2.15.7667
2019.1.11.7296
2018.1.11.6987
2017.2.10.6745
2017.1.9.6501
2016.2.6.6153
2015.1.9.5624
Wwise SDK 2023.1.14
|
依据规定限值削减内存用量并不是一件容易的事。以下是帮助降低内存占用的几个技巧:
Object 内存用量直接受内存中加载的声音和 Event 数量以及游戏对象数量影响。它包含工程中用于实现声音设计的行为所必需的对象的所有属性。它还包含所有游戏对象及其相关信息(游戏同步器值、位置、朝向等)。加载的 SoundBank 越多,所需分配的内存就越多。所需的大小完全取决于在一个场景、关卡、地图、游戏区域等中可能播放的声音数量。您可以采用以下做法来减少这些内存分配:
Processing 类别中的内存用于播放声音。它包含用于解压缩、应用效果器和对音频源做混音的缓冲区。它直接受到同时播放的声音数量的影响。它还受到同时使用的效果器数量和类型的影响。为了节省内存,您需要考虑想同时听到多少声音。某些游戏中很少有超过10种声音的场景,而别的游戏的场景中则可能有数百个声音。您需要考虑最坏的情况。
作为参照指南,我们对一些游戏执行了性能分析(在Xbox One 上),并获得了以下数据:
为了降低处理所需的内存用量,您需要减少同时播放的声部数。通过以下方式可以做到这一点:
info | 备注: 您还可以对总线也设置限制。 |
info | 备注: 您可以在运行时以编程的方式更改音量阈值。您可以在游戏中 CPU 运算更繁重的位置使用此设置,以将更多的声部发送到“低于音量阈值”的状态。 |
SoundBank 占用的内存量几乎都取决于 SoundBank 中的声音数据。控制媒体所占用的内存量可通过以下方式来做到:
Wwise 会使用内部内存池管理部分存续时间不超过一个 Audio Render 时钟周期的临时分配。这些临时分配在 Memory 选项卡的 Advanced Profiler 中显示为 Temp Alloc。它们会存在一段时间、开销很小,由声音引擎在内部进行处理,且无法传给开发者提供的内存分配挂钩。在这当中,Advanced Profiler 和内存分配挂钩只能监控到临时分配所基于的较大内存块。因此,为了更好地优化游戏中的内存用量,最好手动调节 Temp Alloc 内存块的管理。
在 AK::MemoryMgr::Init
过程中,各个 Temp Alloc 类别的内存块的行为由 AkMemSettings::tempAllocSettings
控制。其中包括配置内存块的大小、限定系统至少要分配多少个内存块、规定一个时钟周期积存多少未使用的内存块系统才会释放内存。You can use AK::GetTempAllocStats()
to see how much memory the Temp Alloc system uses in your game at runtime, and better fine tune configuration of the system.
您可以参照以下建议并根据游戏的具体要求或性能分析期间观察到的其他行为实施调节:
AK::TempAllocInitSettings::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::TempAllocStats::uPeakMemUsed
to view the Temp Alloc system's peak memory usage, and then ensure that the AK::TempAllocInitSettings::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::TempAllocInitSettings::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::TempAllocInitSettings::uMinimumBlockSize
so that using more workers does not cause a significant increase in used memory in your game.AK::TempAllocInitSettings::uMinimumBlockSize
to a slightly reduced value than intended in order to mitigate waste in this regard.Some debugging options are available in AK::TempAllocInitSettings
. In the Debug and Profile configuration of the sound engine, AK::TempAllocInitSettings::bDebugDetailedStats
and AK::TempAllocInitSettings::bDebugEnableSentinels
are enabled by default in order to improve tracking of usage statistics, and to provide some easy detection of buffer overruns. 在需要最大限度地提升性能或获取尽可能精确的性能分析数据时,请禁用这些选项。在声音引擎的 Release 配置中,已完全取消对这些选项的支持。
If your Memory Manager integration relies on Wwise's integration of rpmalloc, it might be desirable to adjust AK::MemSettings::uVMSpanCount
and AK::MemSettings::uDeviceSpanCount
in order to reduce the amount of memory reserved by the system. There are three options available for these settings, which provide different trade-offs for CPU and Memory use: AkSpanCount_Small
, AkSpanCount_Medium
, and AkSpanCount_Huge
.
AkSpanCount_Huge
is the default value, which offers the best CPU performance by reducing the number of calls made to AkMemSettings::pfAllocVM
, but also because in supported integrations, and on some platforms, memory mappings can be made using 2MiB pages, instead of 4KiB or 16KiB pages. Utilization of 2MiB pages can reduce the number of translation lookaside buffer (TLB) misses during sound engine execution, and help improve overall CPU performance.
AkSpanCount_Small
adjusts the amount of memory requested at any given time to be as low as 64KiB. This can reduce the amount of memory reserved by Wwise, but can increase the amount of CPU usage due to an increase in calls to AkMemSettings::pfAllocVM
. Depending on your implementation of the AkMemSettings::pfAllocVM
callback, this might also prevent the usage of 2MiB pages for memory mappings.
AkSpanCount_Medium
balances memory and CPU usage, by requesting memory blocks as low as 512KiB. This can reduce the number of calls to AkMemSettings::pfAllocVM
compared to AkSpanCount_Small
, but still might prevent the usage of 2MiB pages for memory mappings.
info | 备注: If your implementation of AkMemSettings::pfAllocVM provides blocks of pre-mapped memory, and rarely invokes a system call for a new memory mapping, we strongly recommend that you use a setting of AkSpanCount_Small because the relative cost of calls to AkMemSettings::pfAllocVM should be greatly reduced, and your pre-mapped memory might already be using 2MiB pages. |