Search.TryToGCDuringMissingIndexing
Search.TryToGCDuringMissingIndexing
#Overview
name: Search.TryToGCDuringMissingIndexing
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Tries to GC occasionally while indexing missing items.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Search.TryToGCDuringMissingIndexing is to control whether garbage collection (GC) should be attempted occasionally while indexing missing items in the asset search system.
This setting variable is primarily used by the Asset Search plugin, which is part of the Unreal Engine editor’s asset management system. Based on the callsites, it’s clear that this variable is utilized within the AssetSearchManager.cpp file, which is likely a core component of the Asset Search plugin.
The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as a static boolean variable and linked to the console variable “Search.TryToGCDuringMissingIndexing” using FAutoConsoleVariableRef.
The associated variable bTryToGCDuringMissingIndexing directly interacts with Search.TryToGCDuringMissingIndexing. They share the same value, with bTryToGCDuringMissingIndexing being used in the actual code logic.
Developers must be aware that enabling this variable may impact performance during asset indexing. It allows for garbage collection to occur while indexing missing items, which could potentially slow down the indexing process but may help manage memory usage.
Best practices when using this variable include:
- Only enable it if memory management during indexing is a concern.
- Monitor performance impacts when enabled.
- Use it in conjunction with other memory management techniques if needed.
Regarding the associated variable bTryToGCDuringMissingIndexing:
The purpose of bTryToGCDuringMissingIndexing is to serve as the actual boolean flag used in the code to determine whether to attempt garbage collection during missing item indexing.
This variable is used within the AssetSearchManager.cpp file, specifically within the FUnloadPackageScope class. It affects the behavior of asset loading and unloading during the search indexing process.
The value of bTryToGCDuringMissingIndexing is set by the console variable Search.TryToGCDuringMissingIndexing.
This variable interacts directly with the FUnloadPackageScope class, influencing whether certain actions are taken during object construction, destruction, and unloading.
Developers should be aware that this variable directly impacts the behavior of the FUnloadPackageScope class, which seems to manage package loading and unloading during the indexing process.
Best practices for using bTryToGCDuringMissingIndexing include:
- Understand the performance implications of enabling garbage collection during indexing.
- Use it in conjunction with proper memory profiling to ensure it’s addressing the intended memory management issues.
- Be cautious when modifying its behavior, as it could affect the stability of the asset search system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Editor/AssetSearch/Source/Private/AssetSearchManager.cpp:64
Scope: file
Source code excerpt:
static bool bTryToGCDuringMissingIndexing = false;
FAutoConsoleVariableRef CVarTryToGCDuringMissingIndexing(
TEXT("Search.TryToGCDuringMissingIndexing"),
bTryToGCDuringMissingIndexing,
TEXT("Tries to GC occasionally while indexing missing items.")
);
//DEFINE_LOG_CATEGORY_STATIC(LogAssetSearch, Log, All);
#Associated Variable and Callsites
This variable is associated with another variable named bTryToGCDuringMissingIndexing
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Editor/AssetSearch/Source/Private/AssetSearchManager.cpp:62
Scope: file
Source code excerpt:
);
static bool bTryToGCDuringMissingIndexing = false;
FAutoConsoleVariableRef CVarTryToGCDuringMissingIndexing(
TEXT("Search.TryToGCDuringMissingIndexing"),
bTryToGCDuringMissingIndexing,
TEXT("Tries to GC occasionally while indexing missing items.")
);
//DEFINE_LOG_CATEGORY_STATIC(LogAssetSearch, Log, All);
class FUnloadPackageScope
#Loc: <Workspace>/Engine/Plugins/Editor/AssetSearch/Source/Private/AssetSearchManager.cpp:76
Scope (from outer to inner):
file
class class FUnloadPackageScope
function FUnloadPackageScope
Source code excerpt:
FUnloadPackageScope()
{
if (bTryToGCDuringMissingIndexing)
{
FCoreUObjectDelegates::OnAssetLoaded.AddRaw(this, &FUnloadPackageScope::OnAssetLoaded);
}
}
~FUnloadPackageScope()
{
if (bTryToGCDuringMissingIndexing)
{
FCoreUObjectDelegates::OnAssetLoaded.RemoveAll(this);
TryUnload(true);
}
}
int32 TryUnload(bool bResetTrackedObjects)
{
if (!bTryToGCDuringMissingIndexing)
{
return 0;
}
TArray<TWeakObjectPtr<UObject>> PackageObjectPtrs;