PackageTools.UnloadPackagesUnloadsPrimaryAssets
PackageTools.UnloadPackagesUnloadsPrimaryAssets
#Overview
name: PackageTools.UnloadPackagesUnloadsPrimaryAssets
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
During unload packages, also unload primary assets
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of PackageTools.UnloadPackagesUnloadsPrimaryAssets is to control whether primary assets should be unloaded during the package unloading process in Unreal Engine.
This setting variable is primarily used by the UnrealEd module, specifically within the PackageTools system. It affects the package unloading functionality, which is a crucial part of the asset management and memory optimization in Unreal Engine.
The value of this variable is set through a console variable (CVar) system. It is initialized as a static boolean variable with a default value of true and then exposed as a console variable using FAutoConsoleVariableRef.
The associated variable bUnloadPackagesUnloadsPrimaryAssets directly interacts with PackageTools.UnloadPackagesUnloadsPrimaryAssets. They share the same value and purpose.
Developers must be aware that this variable affects the behavior of the UnloadPackages function in the UPackageTools class. When set to true, it causes the function to also unload primary assets associated with the packages being unloaded.
Best practices when using this variable include:
- Be cautious when changing its value, as it can affect memory management and asset loading behavior.
- Consider the implications on performance and asset availability when deciding whether to unload primary assets along with packages.
- Use it in conjunction with other asset management tools and practices to optimize memory usage and loading times.
Regarding the associated variable bUnloadPackagesUnloadsPrimaryAssets:
- Its purpose is identical to PackageTools.UnloadPackagesUnloadsPrimaryAssets.
- It is used within the UnloadPackages function of the UPackageTools class.
- Its value is set by the console variable system, same as PackageTools.UnloadPackagesUnloadsPrimaryAssets.
- It directly controls whether the UAssetManager::UnloadPrimaryAsset function is called for each object with a valid PrimaryAssetId during the package unloading process.
- Developers should be aware that modifying this variable will directly impact the behavior of the UnloadPackages function.
- Best practices for using this variable are the same as those for PackageTools.UnloadPackagesUnloadsPrimaryAssets, as they are essentially the same setting.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PackageTools.cpp:73
Scope (from outer to inner):
file
namespace PackageTools_Private
Source code excerpt:
{
static bool bUnloadPackagesUnloadsPrimaryAssets = true;
FAutoConsoleVariableRef CVarUnloadPackagesUnloadsPrimaryAssets(TEXT("PackageTools.UnloadPackagesUnloadsPrimaryAssets"), bUnloadPackagesUnloadsPrimaryAssets, TEXT("During unload packages, also unload primary assets"), ECVF_Default);
}
/** State passed to RestoreStandaloneOnReachableObjects. */
TSet<UPackage*>* UPackageTools::PackagesBeingUnloaded = nullptr;
TSet<UObject*> UPackageTools::ObjectsThatHadFlagsCleared;
FDelegateHandle UPackageTools::ReachabilityCallbackHandle;
#Associated Variable and Callsites
This variable is associated with another variable named bUnloadPackagesUnloadsPrimaryAssets
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PackageTools.cpp:72
Scope (from outer to inner):
file
namespace PackageTools_Private
Source code excerpt:
namespace PackageTools_Private
{
static bool bUnloadPackagesUnloadsPrimaryAssets = true;
FAutoConsoleVariableRef CVarUnloadPackagesUnloadsPrimaryAssets(TEXT("PackageTools.UnloadPackagesUnloadsPrimaryAssets"), bUnloadPackagesUnloadsPrimaryAssets, TEXT("During unload packages, also unload primary assets"), ECVF_Default);
}
/** State passed to RestoreStandaloneOnReachableObjects. */
TSet<UPackage*>* UPackageTools::PackagesBeingUnloaded = nullptr;
TSet<UObject*> UPackageTools::ObjectsThatHadFlagsCleared;
FDelegateHandle UPackageTools::ReachabilityCallbackHandle;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PackageTools.cpp:495
Scope (from outer to inner):
file
function bool UPackageTools::UnloadPackages
Source code excerpt:
{
// Asset manager can hold hard references to this object and prevent GC
if (PackageTools_Private::bUnloadPackagesUnloadsPrimaryAssets)
{
const FPrimaryAssetId PrimaryAssetId = UAssetManager::Get().GetPrimaryAssetIdForObject(Obj);
if (PrimaryAssetId.IsValid())
{
UAssetManager::Get().UnloadPrimaryAsset(PrimaryAssetId);
}