au.streamcaching.MemoryLimitTrimPercentage
au.streamcaching.MemoryLimitTrimPercentage
#Overview
name: au.streamcaching.MemoryLimitTrimPercentage
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When set > 0.0, we will trim percentage of memory cache audio per trim call audio when the stream cache goes over the memory limit.\n0.0: trims only the amount needed to allocate a single chunk, >0: that percentage of memory limit.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.streamcaching.MemoryLimitTrimPercentage is to control the amount of memory trimmed from the audio streaming cache when it exceeds the memory limit. This setting is part of Unreal Engine’s audio streaming system.
The Unreal Engine subsystem that relies on this setting variable is the audio streaming cache, specifically within the Engine module. This can be seen from the file path where the variable is defined and used: Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp.
The value of this variable is set through a console variable (CVar) system, which allows it to be modified at runtime. It’s initialized with a default value of 0.1f (10%) and can be changed using the console command “au.streamcaching.MemoryLimitTrimPercentage”.
This variable interacts closely with its associated variable MemoryLimitTrimPercentageCVar. They share the same value, with MemoryLimitTrimPercentageCVar being the actual storage for the value, while au.streamcaching.MemoryLimitTrimPercentage is the console-accessible name.
Developers must be aware that:
- When set to 0.0, the system will only trim the amount needed to allocate a single chunk.
- When set to a value greater than 0.0, it will trim that percentage of the memory limit per trim call.
- The value is clamped between 0.0 and 1.0 (0% to 100%) when used in calculations.
Best practices when using this variable include:
- Adjust it based on the game’s audio requirements and available memory.
- Monitor its impact on audio performance and memory usage.
- Consider platform-specific adjustments, as memory constraints may vary.
Regarding the associated variable MemoryLimitTrimPercentageCVar:
- Its purpose is to store the actual value of the trim percentage.
- It’s used directly in the code to perform memory trimming calculations.
- It’s initialized with a default value of 0.1f (10%).
- It’s accessed in multiple functions within the FAudioChunkCache class to determine how much memory to trim when the cache exceeds its limit.
- Developers should be aware that modifying MemoryLimitTrimPercentageCVar directly in code will affect the behavior of the audio streaming cache, but it’s generally better to use the console variable for runtime adjustments.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:96
Scope: file
Source code excerpt:
static float MemoryLimitTrimPercentageCVar = 0.1f;
FAutoConsoleVariableRef CVarMemoryLimitTrimPercentage(
TEXT("au.streamcaching.MemoryLimitTrimPercentage"),
MemoryLimitTrimPercentageCVar,
TEXT("When set > 0.0, we will trim percentage of memory cache audio per trim call audio when the stream cache goes over the memory limit.\n")
TEXT("0.0: trims only the amount needed to allocate a single chunk, >0: that percentage of memory limit."),
ECVF_Default);
static float StreamCacheSizeOverrideMBCVar = 0.0f;
#Associated Variable and Callsites
This variable is associated with another variable named MemoryLimitTrimPercentageCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:94
Scope: file
Source code excerpt:
ECVF_Default);
static float MemoryLimitTrimPercentageCVar = 0.1f;
FAutoConsoleVariableRef CVarMemoryLimitTrimPercentage(
TEXT("au.streamcaching.MemoryLimitTrimPercentage"),
MemoryLimitTrimPercentageCVar,
TEXT("When set > 0.0, we will trim percentage of memory cache audio per trim call audio when the stream cache goes over the memory limit.\n")
TEXT("0.0: trims only the amount needed to allocate a single chunk, >0: that percentage of memory limit."),
ECVF_Default);
static float StreamCacheSizeOverrideMBCVar = 0.0f;
FAutoConsoleVariableRef CVarStreamCacheSizeOverrideMB(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:826
Scope (from outer to inner):
file
function uint64 FAudioChunkCache::AddOrTouchChunk
Source code excerpt:
{
uint64 MemoryToTrim = 0;
if (MemoryLimitTrimPercentageCVar > 0.0f)
{
MemoryToTrim = MemoryLimitBytes * FMath::Min(MemoryLimitTrimPercentageCVar, 1.0f);
}
else
{
MemoryToTrim = MemoryUsageBytes - MemoryLimitBytes;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:1056
Scope (from outer to inner):
file
function void FAudioChunkCache::AddForceInlineSoundWave
Source code excerpt:
{
uint64 MemoryToTrim = 0;
if (MemoryLimitTrimPercentageCVar > 0.0f)
{
MemoryToTrim = MemoryLimitBytes * FMath::Min(MemoryLimitTrimPercentageCVar, 1.0f);
}
else
{
MemoryToTrim = MemoryUsageBytes - MemoryLimitBytes;
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:1115
Scope (from outer to inner):
file
function void FAudioChunkCache::AddMemoryCountedFeature
Source code excerpt:
{
uint64 MemoryToTrim = 0;
if (MemoryLimitTrimPercentageCVar > 0.0f)
{
MemoryToTrim = MemoryLimitBytes * FMath::Min(MemoryLimitTrimPercentageCVar, 1.0f);
}
else
{
MemoryToTrim = MemoryUsageBytes - MemoryLimitBytes;
}