au.streamcaching.StreamCacheSizeOverrideMB
au.streamcaching.StreamCacheSizeOverrideMB
#Overview
name: au.streamcaching.StreamCacheSizeOverrideMB
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This cvar can be set to override the size of the cache.\n0: use cache size from project settings. n: the new cache size in megabytes.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of au.streamcaching.StreamCacheSizeOverrideMB is to override the size of the audio streaming cache in Unreal Engine 5. This setting variable is part of the audio streaming system, which is responsible for managing the memory used for streaming audio assets.
This setting variable is primarily used in the Engine module, specifically within the audio streaming cache subsystem. It’s defined and referenced in the AudioStreamingCache.cpp file, which is part of the audio streaming implementation.
The value of this variable is set through the Unreal Engine console variable (CVar) system. It can be modified at runtime using console commands or through configuration files.
The associated variable StreamCacheSizeOverrideMBCVar directly interacts with au.streamcaching.StreamCacheSizeOverrideMB. They share the same value, with StreamCacheSizeOverrideMBCVar being the actual float variable that stores the cache size override value.
Developers should be aware that:
- The default value is 0.0f, which means the cache size from project settings is used.
- Setting a value greater than 0 will override the cache size, specifying it in megabytes.
- This variable affects the memory usage of the audio streaming system, so it should be used carefully to avoid excessive memory consumption.
Best practices when using this variable include:
- Only override the cache size when necessary, as the project settings are typically optimized for most use cases.
- Monitor memory usage when modifying this value to ensure it doesn’t negatively impact overall performance.
- Consider the target platform’s memory constraints when setting a custom cache size.
Regarding the associated variable StreamCacheSizeOverrideMBCVar:
- It’s a static float variable that directly stores the value set by au.streamcaching.StreamCacheSizeOverrideMB.
- It’s used in the FAudioChunkCache::AddOrTouchChunk function to update the cache limit if a non-zero value is set.
- When using this variable, developers should ensure that any code accessing it checks for near-zero values (FMath::IsNearlyZero) to determine if the override is active.
- The same best practices and awareness points apply to this variable as they do to au.streamcaching.StreamCacheSizeOverrideMB.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:104
Scope: file
Source code excerpt:
static float StreamCacheSizeOverrideMBCVar = 0.0f;
FAutoConsoleVariableRef CVarStreamCacheSizeOverrideMB(
TEXT("au.streamcaching.StreamCacheSizeOverrideMB"),
StreamCacheSizeOverrideMBCVar,
TEXT("This cvar can be set to override the size of the cache.\n")
TEXT("0: use cache size from project settings. n: the new cache size in megabytes."),
ECVF_Default);
static int32 SaveAudioMemReportOnCacheOverflowCVar = 0;
#Associated Variable and Callsites
This variable is associated with another variable named StreamCacheSizeOverrideMBCVar
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:102
Scope: file
Source code excerpt:
ECVF_Default);
static float StreamCacheSizeOverrideMBCVar = 0.0f;
FAutoConsoleVariableRef CVarStreamCacheSizeOverrideMB(
TEXT("au.streamcaching.StreamCacheSizeOverrideMB"),
StreamCacheSizeOverrideMBCVar,
TEXT("This cvar can be set to override the size of the cache.\n")
TEXT("0: use cache size from project settings. n: the new cache size in megabytes."),
ECVF_Default);
static int32 SaveAudioMemReportOnCacheOverflowCVar = 0;
FAutoConsoleVariableRef CVarSaveAudiomemReportOnCacheOverflow(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:767
Scope (from outer to inner):
file
function uint64 FAudioChunkCache::AddOrTouchChunk
Source code excerpt:
{
// Update cache limit if needed.
if (!FMath::IsNearlyZero(StreamCacheSizeOverrideMBCVar) && StreamCacheSizeOverrideMBCVar > 0.0f)
{
MemoryLimitBytes = ((uint64)(StreamCacheSizeOverrideMBCVar * 1024)) * 1024;
}
if (!InSoundWaveData.IsValid())
{
ExecuteOnLoadCompleteCallback(EAudioChunkLoadResult::ChunkOutOfBounds, OnLoadCompleted, CallbackThread);
return InvalidAudioStreamCacheLookupID;