r.PurgeEditorSceneDuringPIE

r.PurgeEditorSceneDuringPIE

#Overview

name: r.PurgeEditorSceneDuringPIE

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 r.PurgeEditorSceneDuringPIE is to control the memory management of the editor scene during Play-In-Editor (PIE) sessions in Unreal Engine 5.

This setting variable is primarily used by the Engine module, specifically within the World management system. It’s referenced in the Engine/Source/Runtime/Engine/Private/World.cpp file, which is a core part of the Unreal Engine’s runtime.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0, which means the editor scene is kept fully initialized during PIE by default.

The associated variable CVarPurgeEditorSceneDuringPIE directly interacts with r.PurgeEditorSceneDuringPIE. They share the same value and purpose.

Developers must be aware that changing this variable can significantly impact memory usage and performance during PIE sessions. When set to 1, it causes the editor scene to be purged from memory during PIE and restored when the session finishes. This can potentially free up memory but might also introduce additional loading times when switching between PIE and editor modes.

Best practices when using this variable include:

  1. Only enable it (set to 1) if memory constraints are a significant issue during PIE.
  2. Be prepared for potential increases in load times when exiting PIE if enabled.
  3. Test thoroughly to ensure that purging and restoring the editor scene doesn’t introduce any unexpected behavior in your specific project.

Regarding the associated variable CVarPurgeEditorSceneDuringPIE:

The purpose of CVarPurgeEditorSceneDuringPIE is identical to r.PurgeEditorSceneDuringPIE. It’s the actual console variable that controls the behavior.

This variable is used in the UWorld::PurgeScene function to determine whether to proceed with purging the scene or not. If the value is 0, the function returns early without purging the scene.

The value of CVarPurgeEditorSceneDuringPIE can be changed at runtime through console commands, allowing developers to adjust the behavior without recompiling the engine.

Developers should be aware that this variable is checked on the game thread (GetValueOnGameThread()), which means changes to it will only take effect on the next frame or PIE session.

Best practices for CVarPurgeEditorSceneDuringPIE are the same as for r.PurgeEditorSceneDuringPIE, as they are essentially the same setting. Developers should use this variable name when accessing the setting programmatically or through console commands.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:152

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarPurgeEditorSceneDuringPIE(
	TEXT("r.PurgeEditorSceneDuringPIE"),
	0,
	TEXT("0 to keep editor scene fully initialized during PIE (default)\n")
	TEXT("1 to purge editor scene from memory during PIE and restore when the session finishes."));

/*-----------------------------------------------------------------------------
	FAdaptiveAddToWorld implementation.

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:151

Scope: file

Source code excerpt:



static TAutoConsoleVariable<int32> CVarPurgeEditorSceneDuringPIE(
	TEXT("r.PurgeEditorSceneDuringPIE"),
	0,
	TEXT("0 to keep editor scene fully initialized during PIE (default)\n")
	TEXT("1 to purge editor scene from memory during PIE and restore when the session finishes."));

/*-----------------------------------------------------------------------------

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:9018

Scope (from outer to inner):

file
function     void UWorld::PurgeScene

Source code excerpt:

void UWorld::PurgeScene()
{
	if (CVarPurgeEditorSceneDuringPIE.GetValueOnGameThread() == 0)
	{
		return;
	}

	if (!bPurgedScene && this->IsEditorWorld())
	{