LogGameThreadMallocChurn.Threshhold
LogGameThreadMallocChurn.Threshhold
#Overview
name: LogGameThreadMallocChurn.Threshhold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Minimum average number of allocs per frame to include in the report.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LogGameThreadMallocChurn.Threshhold is to set a minimum threshold for reporting memory allocation churn on the game thread. This setting is part of Unreal Engine’s performance monitoring and debugging system, specifically focusing on memory allocation patterns.
This setting variable is primarily used in the Launch module of Unreal Engine, as evidenced by its location in the LaunchEngineLoop.cpp file. It’s part of a larger system that monitors and reports on memory allocation behavior in the game thread.
The value of this variable is set using a TAutoConsoleVariable, which means it can be adjusted at runtime through the console. Its default value is set to 10, as seen in the source code.
This variable interacts closely with other related variables, particularly:
- CVarLogGameThreadMallocChurn_SampleFrequency
- CVarLogGameThreadMallocChurn_PrintFrequency
These variables work together to control the frequency and threshold of memory allocation churn reporting.
Developers should be aware that this variable directly affects the sensitivity of the memory churn reporting system. A lower threshold will result in more detailed reports but may also increase overhead. Conversely, a higher threshold will only report on more significant allocation events.
Best practices when using this variable include:
- Adjusting the threshold based on the specific needs of the project. For performance-critical applications, a higher threshold might be preferred to reduce overhead.
- Using this in conjunction with the other related variables to fine-tune the reporting system.
- Being cautious about setting the threshold too low in production builds, as it could potentially impact performance.
Regarding the associated variable CVarLogGameThreadMallocChurn_Threshhold, it is essentially the same variable. The duplicate declaration seems to be a typo in the variable name (notice the extra ‘h’ in “Threshhold”). This duplication doesn’t change its functionality, but it’s worth noting that this might be a mistake in the codebase. The same considerations and best practices apply to this variable as well.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5402
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_Threshhold(
TEXT("LogGameThreadMallocChurn.Threshhold"),
10,
TEXT("Minimum average number of allocs per frame to include in the report."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_SampleFrequency(
TEXT("LogGameThreadMallocChurn.SampleFrequency"),
100,
#Associated Variable and Callsites
This variable is associated with another variable named CVarLogGameThreadMallocChurn_Threshhold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5401
Scope: file
Source code excerpt:
TEXT("Number of frames between churn reports."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_Threshhold(
TEXT("LogGameThreadMallocChurn.Threshhold"),
10,
TEXT("Minimum average number of allocs per frame to include in the report."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_SampleFrequency(
TEXT("LogGameThreadMallocChurn.SampleFrequency"),
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5501
Scope (from outer to inner):
file
function void PrintResultsAndReset
Source code excerpt:
FOutputDeviceRedirector* Log = FOutputDeviceRedirector::Get();
float SampleAndFrameCorrection = float(CVarLogGameThreadMallocChurn_SampleFrequency.GetValueOnGameThread()) / float(CVarLogGameThreadMallocChurn_PrintFrequency.GetValueOnGameThread());
GGameThreadMallocChurnTracker.DumpStackTraces(CVarLogGameThreadMallocChurn_Threshhold.GetValueOnGameThread(), *Log, SampleAndFrameCorrection);
GGameThreadMallocChurnTracker.ResetTracking();
}
};
FStackTracker FScopedSampleMallocChurn::GGameThreadMallocChurnTracker;
uint64 FScopedSampleMallocChurn::DumpFrame = 0;