r.DemotedLocalMemoryWarning
r.DemotedLocalMemoryWarning
#Overview
name: r.DemotedLocalMemoryWarning
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If set to 1, a warning will be displayed when local memory has been demoted to system memory.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of r.DemotedLocalMemoryWarning is to control whether a warning is displayed when local memory has been demoted to system memory. This setting is primarily related to the rendering system and memory management in Unreal Engine 5.
The Unreal Engine subsystem that relies on this setting variable is the Renderer module, specifically within the scene rendering process. This is evident from its usage in the SceneRendering.cpp file.
The value of this variable is set using a TAutoConsoleVariable, which allows it to be changed at runtime through the console. By default, it is set to 1, meaning the warning is enabled.
The associated variable CVarDemotedLocalMemoryWarning interacts directly with r.DemotedLocalMemoryWarning. It’s used to access the current value of the setting in the rendering code.
Developers must be aware that this variable affects the visibility of warnings related to memory management. When enabled (set to 1), it will trigger a warning if local memory has been demoted to system memory, which could indicate potential performance issues.
Best practices when using this variable include:
- Keep it enabled (set to 1) during development to catch potential memory issues early.
- Consider disabling it (set to 0) in release builds if the warnings are not needed for end-users.
- Use it in conjunction with profiling tools to identify and address memory management issues.
Regarding the associated variable CVarDemotedLocalMemoryWarning:
The purpose of CVarDemotedLocalMemoryWarning is to provide a convenient way to access the value of r.DemotedLocalMemoryWarning within the C++ code.
This variable is used within the Renderer module, specifically in the FSceneRenderer::OnRenderFinish function.
The value of CVarDemotedLocalMemoryWarning is set by finding the console variable data for “r.DemotedLocalMemoryWarning” using the IConsoleManager.
It interacts directly with r.DemotedLocalMemoryWarning and is used to control the visibility of the demoted local memory warning.
Developers should be aware that CVarDemotedLocalMemoryWarning is a pointer to the console variable data, and its value should be checked for null before use.
Best practices for using CVarDemotedLocalMemoryWarning include:
- Always check if the pointer is valid before dereferencing it.
- Use GetValueOnRenderThread() when accessing its value in render thread code.
- Consider caching the pointer for performance if it’s accessed frequently, but be aware of potential changes to the console variable during runtime.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:4094
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDemotedLocalMemoryWarning(
TEXT("r.DemotedLocalMemoryWarning"),
1,
TEXT("If set to 1, a warning will be displayed when local memory has been demoted to system memory."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarFeatureLevelPreview(
TEXT("r.FeatureLevelPreview"),
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3678
Scope (from outer to inner):
file
function void FSceneRenderer::OnRenderFinish
Source code excerpt:
bool bShowDemotedLocalMemoryWarning = false;
static const auto* CVarDemotedLocalMemoryWarning = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DemotedLocalMemoryWarning"));
if (CVarDemotedLocalMemoryWarning && CVarDemotedLocalMemoryWarning->GetValueOnRenderThread() == 1)
{
bShowDemotedLocalMemoryWarning = GDemotedLocalMemorySize > 0;
}
bool bShowGlobalClipPlaneWarning = false;
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemotedLocalMemoryWarning
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp:4093
Scope: file
Source code excerpt:
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarDemotedLocalMemoryWarning(
TEXT("r.DemotedLocalMemoryWarning"),
1,
TEXT("If set to 1, a warning will be displayed when local memory has been demoted to system memory."),
ECVF_RenderThreadSafe);
static TAutoConsoleVariable<int32> CVarFeatureLevelPreview(
#Loc: <Workspace>/Engine/Source/Runtime/Renderer/Private/SceneRendering.cpp:3678
Scope (from outer to inner):
file
function void FSceneRenderer::OnRenderFinish
Source code excerpt:
bool bShowDemotedLocalMemoryWarning = false;
static const auto* CVarDemotedLocalMemoryWarning = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.DemotedLocalMemoryWarning"));
if (CVarDemotedLocalMemoryWarning && CVarDemotedLocalMemoryWarning->GetValueOnRenderThread() == 1)
{
bShowDemotedLocalMemoryWarning = GDemotedLocalMemorySize > 0;
}
bool bShowGlobalClipPlaneWarning = false;