au.streamcaching.MemoryLimitTrimPercentage

au.streamcaching.MemoryLimitTrimPercentage

#Overview

name: au.streamcaching.MemoryLimitTrimPercentage

This variable is created as a Console Variable (cvar).

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:

  1. When set to 0.0, the system will only trim the amount needed to allocate a single chunk.
  2. When set to a value greater than 0.0, it will trim that percentage of the memory limit per trim call.
  3. The value is clamped between 0.0 and 1.0 (0% to 100%) when used in calculations.

Best practices when using this variable include:

  1. Adjust it based on the game’s audio requirements and available memory.
  2. Monitor its impact on audio performance and memory usage.
  3. Consider platform-specific adjustments, as memory constraints may vary.

Regarding the associated variable MemoryLimitTrimPercentageCVar:

#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;
		}