gc.MaxObjectsNotConsideredByGC

gc.MaxObjectsNotConsideredByGC

#Overview

name: gc.MaxObjectsNotConsideredByGC

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

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 gc.MaxObjectsNotConsideredByGC is to set a threshold for the number of objects that the Unreal Engine’s Garbage Collection system will not consider during its collection process. This setting is primarily related to the memory management and garbage collection subsystem of Unreal Engine.

Based on the callsites, this setting variable is mainly used in the CoreUObject module of Unreal Engine. It’s particularly relevant to the garbage collection settings and object management system.

The value of this variable is set in multiple ways:

  1. It’s initially defined as a console variable using FAutoConsoleVariableRef.
  2. It can be set through the engine configuration file (GEngineIni) in the “/Script/Engine.GarbageCollectionSettings” section.
  3. In some cases, like in the ReplicationSystemTest, it’s explicitly set to 0 in the configuration.

This variable interacts with other garbage collection-related variables, such as GSizeOfPermanentObjectPool, which is often configured alongside MaxObjectsNotConsideredByGC.

Developers should be aware that:

  1. This variable is marked as a “Placeholder console variable, currently not used in runtime” in the source code comment, which suggests its functionality might be limited or subject to change.
  2. Its value can be overridden in different contexts, such as in test environments or specific game configurations.

Best practices when using this variable include:

  1. Be cautious about modifying its value, as it could potentially impact the performance of the garbage collection system.
  2. Always test thoroughly after changing this value to ensure it doesn’t negatively affect your game’s performance or memory usage.
  3. Consider the implications on different platforms, as the comment suggests it might behave differently on PC versus other platforms.
  4. Keep track of any changes to this variable across different engine versions, as its functionality or impact might evolve over time.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1518, section: [/Script/Engine.GarbageCollectionSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectBase.cpp:931

Scope: file

Source code excerpt:

static int32 GVarMaxObjectsNotConsideredByGC;
static FAutoConsoleVariableRef CMaxObjectsNotConsideredByGC(
	TEXT("gc.MaxObjectsNotConsideredByGC"),
	GVarMaxObjectsNotConsideredByGC,
	TEXT("Placeholder console variable, currently not used in runtime."),
	ECVF_Default
	);

static int32 GSizeOfPermanentObjectPool;

#Loc: <Workspace>/Engine/Source/Programs/ReplicationSystemTest/Private/ReplicationSystemTest.cpp:163

Scope (from outer to inner):

file
function     static void PreInit

Source code excerpt:


	// Config overrides
	GConfig->SetInt(TEXT("/Script/Engine.GarbageCollectionSettings"), TEXT("gc.MaxObjectsNotConsideredByGC"), 0, GEngineIni);
	GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("AIControllerClassName"), TEXT("/Script/AIModule.AIController"), GEngineIni);
	GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("DefaultMaterialName"), TEXT("/Engine/Transient.MockDefaultMaterial"), GEngineIni);
	GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("DefaultLightFunctionMaterialName"), TEXT("/Engine/Transient.MockDefaultMaterial"), GEngineIni);
	GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("DefaultDeferredDecalMaterialName"), TEXT("/Engine/Transient.MockDefaultMaterial"), GEngineIni);
	GConfig->SetString(TEXT("/Script/Engine.Engine"), TEXT("DefaultPostProcessMaterialName"), TEXT("/Engine/Transient.MockDefaultMaterial"), GEngineIni);

#Loc: <Workspace>/Engine/Source/Runtime/CoreUObject/Private/UObject/UObjectBase.cpp:988

Scope (from outer to inner):

file
function     void UObjectBaseInit

Source code excerpt:

		else
		{
			GConfig->GetInt(TEXT("/Script/Engine.GarbageCollectionSettings"), TEXT("gc.MaxObjectsNotConsideredByGC"), MaxObjectsNotConsideredByGC, GEngineIni);

			// Not used on PC as in-place creation inside bigger pool interacts with the exit purge and deleting UObject directly.
			GConfig->GetInt(TEXT("/Script/Engine.GarbageCollectionSettings"), TEXT("gc.SizeOfPermanentObjectPool"), SizeOfPermanentObjectPool, GEngineIni);
		}

		// Maximum number of UObjects in cooked game