LogGameThreadMallocChurn.RemoveAliases

LogGameThreadMallocChurn.RemoveAliases

#Overview

name: LogGameThreadMallocChurn.RemoveAliases

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LogGameThreadMallocChurn.RemoveAliases is to control the behavior of memory churn tracking in the game thread, specifically whether to remove aliases from the counting process during stack trace capture.

This setting variable is primarily used in the Unreal Engine’s core runtime system, specifically in the game thread memory allocation tracking subsystem. It’s part of the engine’s performance profiling and debugging tools.

The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as a TAutoConsoleVariable with a default value of 1, meaning alias removal is enabled by default.

The associated variable CVarLogGameThreadMallocChurn_RemoveAliases directly interacts with LogGameThreadMallocChurn.RemoveAliases. They share the same value and purpose.

Developers must be aware that enabling this variable (value > 0) will merge addresses that have the same human-readable string in the memory churn tracking process. This can provide a more consolidated view of memory usage but at the cost of increased processing time.

Best practices when using this variable include:

  1. Keep it enabled (default value of 1) for general profiling to get a cleaner, merged view of memory usage.
  2. Disable it (set to 0) if you need more granular, address-specific information or if performance during profiling becomes an issue.
  3. Use in conjunction with other LogGameThreadMallocChurn variables for comprehensive memory profiling.

Regarding the associated variable CVarLogGameThreadMallocChurn_RemoveAliases:

Its purpose is identical to LogGameThreadMallocChurn.RemoveAliases, serving as the C++ representation of the console variable.

It’s used in the game thread malloc churn tracking system, specifically in the CollectSample function where it determines whether to remove aliases during stack trace capture.

The value is set when the TAutoConsoleVariable is initialized and can be changed at runtime through the console.

It directly interacts with the GGameThreadMallocChurnTracker object, influencing how stack traces are captured and analyzed.

Developers should be aware that this variable is queried on the game thread, so frequent changes might have a minor performance impact.

Best practices include using GetValueOnGameThread() when accessing this variable to ensure thread-safe access, and considering the performance implications when frequently toggling this setting during runtime.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5417

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_RemoveAliases(
	TEXT("LogGameThreadMallocChurn.RemoveAliases"),
	1,
	TEXT("If > 0 then remove aliases from the counting process. This essentialy merges addresses that have the same human readable string. It is slower."));

static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_StackLen(
	TEXT("LogGameThreadMallocChurn.StackLen"),
	3,

#Associated Variable and Callsites

This variable is associated with another variable named CVarLogGameThreadMallocChurn_RemoveAliases. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5416

Scope: file

Source code excerpt:

	TEXT("Number of items to discard from the top of a stack frame."));

static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_RemoveAliases(
	TEXT("LogGameThreadMallocChurn.RemoveAliases"),
	1,
	TEXT("If > 0 then remove aliases from the counting process. This essentialy merges addresses that have the same human readable string. It is slower."));

static TAutoConsoleVariable<int32> CVarLogGameThreadMallocChurn_StackLen(
	TEXT("LogGameThreadMallocChurn.StackLen"),

#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:5494

Scope (from outer to inner):

file
function     void CollectSample

Source code excerpt:

	{
		check(IsInGameThread());
		GGameThreadMallocChurnTracker.CaptureStackTrace(CVarLogGameThreadMallocChurn_StackIgnore.GetValueOnGameThread(), nullptr, CVarLogGameThreadMallocChurn_StackLen.GetValueOnGameThread(), CVarLogGameThreadMallocChurn_RemoveAliases.GetValueOnGameThread() > 0);
	}
	void PrintResultsAndReset()
	{
		DumpFrame = GFrameCounter + CVarLogGameThreadMallocChurn_PrintFrequency.GetValueOnGameThread();
		FOutputDeviceRedirector* Log = FOutputDeviceRedirector::Get();
		float SampleAndFrameCorrection = float(CVarLogGameThreadMallocChurn_SampleFrequency.GetValueOnGameThread()) / float(CVarLogGameThreadMallocChurn_PrintFrequency.GetValueOnGameThread());