LogGameThreadMallocChurn.PrintFrequency
LogGameThreadMallocChurn.PrintFrequency
#Overview
name: LogGameThreadMallocChurn.PrintFrequency
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Number of frames between churn reports.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LogGameThreadMallocChurn.PrintFrequency is to control the frequency of memory allocation churn reports in the game thread. This setting variable is part of Unreal Engine’s memory profiling and debugging system.
This setting variable is primarily used in the Launch module of Unreal Engine, specifically in the LaunchEngineLoop.cpp file. It’s part of a system that monitors and reports on memory allocation churn (frequent allocation and deallocation of memory) in the game thread.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 300, but can be changed at runtime through console commands or configuration files.
LogGameThreadMallocChurn.PrintFrequency interacts with several other variables:
- CVarLogGameThreadMallocChurn: Controls whether the churn tracking is enabled.
- CVarLogGameThreadMallocChurn_SampleFrequency: Determines how often samples are taken.
- CVarLogGameThreadMallocChurn_Threshhold: Sets the threshold for reporting churn.
Developers should be aware that this variable directly affects the frequency of churn reports. Setting it too low might impact performance due to frequent reporting, while setting it too high might miss important churn events.
Best practices for using this variable include:
- Adjust it based on the specific needs of your profiling session.
- Use it in conjunction with the other related variables for a comprehensive view of memory churn.
- Be mindful of its impact on performance, especially in production builds.
The associated variable CVarLogGameThreadMallocChurn_PrintFrequency is an AutoConsoleVariable that directly controls the LogGameThreadMallocChurn.PrintFrequency setting. It’s used to get and set the value of the print frequency at runtime.
The purpose of CVarLogGameThreadMallocChurn_PrintFrequency is to provide a convenient way to access and modify the print frequency setting through the console variable system. It’s used in the same context as LogGameThreadMallocChurn.PrintFrequency, primarily in the memory churn tracking system of the Launch module.
Developers should be aware that changes to CVarLogGameThreadMallocChurn_PrintFrequency will immediately affect the behavior of the churn reporting system. It’s a powerful tool for on-the-fly adjustment of profiling behavior, but should be used judiciously, especially in production environments.
Best practices for CVarLogGameThreadMallocChurn_PrintFrequency include:
- Use it for dynamic adjustment of churn reporting frequency during development and testing.
- Consider exposing it in debug menus for easy access during playtesting.
- Document any non-default values used in specific profiling scenarios for reproducibility.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5397
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_PrintFrequency(
TEXT("LogGameThreadMallocChurn.PrintFrequency"),
300,
TEXT("Number of frames between churn reports."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_Threshhold(
TEXT("LogGameThreadMallocChurn.Threshhold"),
10,
#Associated Variable and Callsites
This variable is associated with another variable named CVarLogGameThreadMallocChurn_PrintFrequency
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5396
Scope: file
Source code excerpt:
TEXT("If > 0, then collect sample game thread malloc, realloc and free, periodically print a report of the worst offenders."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_PrintFrequency(
TEXT("LogGameThreadMallocChurn.PrintFrequency"),
300,
TEXT("Number of frames between churn reports."));
static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_Threshhold(
TEXT("LogGameThreadMallocChurn.Threshhold"),
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5458
Scope (from outer to inner):
file
function FScopedSampleMallocChurn
Source code excerpt:
if (!DumpFrame)
{
DumpFrame = GFrameCounter + CVarLogGameThreadMallocChurn_PrintFrequency.GetValueOnGameThread();
GGameThreadMallocChurnTracker.ResetTracking();
}
GGameThreadMallocChurnTracker.ToggleTracking(true, true);
GGameThreadMallocHook = &Hook;
}
else
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5498
Scope (from outer to inner):
file
function void PrintResultsAndReset
Source code excerpt:
void PrintResultsAndReset()
{
DumpFrame = GFrameCounter + CVarLogGameThreadMallocChurn_PrintFrequency.GetValueOnGameThread();
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;