LLMSnapshot

LLMSnapshot

#Overview

name: LLMSnapshot

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LLMSnapshot is to take a single snapshot of the Low-Level Memory (LLM) usage for one frame in Unreal Engine 5. This feature is part of the memory management and profiling system, specifically the Low-Level Memory Tracker.

The LLMSnapshot functionality is implemented in the Core module of Unreal Engine, within the HAL (Hardware Abstraction Layer) subsystem. It’s defined in the LowLevelMemTracker.cpp file, which is part of the engine’s core runtime.

The value of this variable is set as a console command using the FAutoConsoleCommand class. It’s not a traditional variable, but rather a command that can be executed from the console or through code.

The LLMSnapshot command interacts with the FLowLevelMemTracker class. When executed, it calls the PublishDataSingleFrame() method of the FLowLevelMemTracker instance.

Developers must be aware that this command requires the “-llmdisableautopublish” command line argument to be set. This suggests that there’s an automatic publishing mechanism for LLM data that needs to be disabled for this manual snapshot to work correctly.

Best practices for using this variable (command) include:

  1. Use it for debugging memory issues or profiling memory usage at specific points in time.
  2. Ensure the “-llmdisableautopublish” command line argument is set when using this command.
  3. Be aware that this captures data for a single frame, so timing of when you execute the command is important.

Regarding the associated variable LLMSnapshot, it’s actually the same console command. The code snippet shows the declaration of the FAutoConsoleCommand named LLMSnapshot. This command, when executed, triggers the snapshot functionality. The best practices and usage considerations are the same as mentioned above.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:959

Scope: file

Source code excerpt:

#endif
	TEXT("The maximum total number of characters allowed for all of the LLM titles")
);

FAutoConsoleCommand LLMSnapshot(
	TEXT("LLMSnapshot"), 
	TEXT("Takes a single LLM Snapshot of one frame. This command requires the commandline -llmdisableautopublish"), 
	FConsoleCommandDelegate::CreateLambda([]() 
	{
		FLowLevelMemTracker::Get().PublishDataSingleFrame();
	}));

FAutoConsoleCommand DumpLLM(
	TEXT("DumpLLM"),
	TEXT("Logs out the current and peak sizes of all tracked LLM tags"),
	FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateLambda(
		[](const TArray<FString>& Args, UWorld* InWorld, FOutputDevice& Ar)

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:958

Scope: file

Source code excerpt:

	5000,
#endif
	TEXT("The maximum total number of characters allowed for all of the LLM titles")
);

FAutoConsoleCommand LLMSnapshot(
	TEXT("LLMSnapshot"), 
	TEXT("Takes a single LLM Snapshot of one frame. This command requires the commandline -llmdisableautopublish"), 
	FConsoleCommandDelegate::CreateLambda([]() 
	{
		FLowLevelMemTracker::Get().PublishDataSingleFrame();
	}));

FAutoConsoleCommand DumpLLM(
	TEXT("DumpLLM"),
	TEXT("Logs out the current and peak sizes of all tracked LLM tags"),
	FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateLambda(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:959

Scope: file

Source code excerpt:

#endif
	TEXT("The maximum total number of characters allowed for all of the LLM titles")
);

FAutoConsoleCommand LLMSnapshot(
	TEXT("LLMSnapshot"), 
	TEXT("Takes a single LLM Snapshot of one frame. This command requires the commandline -llmdisableautopublish"), 
	FConsoleCommandDelegate::CreateLambda([]() 
	{
		FLowLevelMemTracker::Get().PublishDataSingleFrame();
	}));

FAutoConsoleCommand DumpLLM(
	TEXT("DumpLLM"),
	TEXT("Logs out the current and peak sizes of all tracked LLM tags"),
	FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateLambda(
		[](const TArray<FString>& Args, UWorld* InWorld, FOutputDevice& Ar)

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/HAL/LowLevelMemTracker.cpp:958

Scope: file

Source code excerpt:

	5000,
#endif
	TEXT("The maximum total number of characters allowed for all of the LLM titles")
);

FAutoConsoleCommand LLMSnapshot(
	TEXT("LLMSnapshot"), 
	TEXT("Takes a single LLM Snapshot of one frame. This command requires the commandline -llmdisableautopublish"), 
	FConsoleCommandDelegate::CreateLambda([]() 
	{
		FLowLevelMemTracker::Get().PublishDataSingleFrame();
	}));

FAutoConsoleCommand DumpLLM(
	TEXT("DumpLLM"),
	TEXT("Logs out the current and peak sizes of all tracked LLM tags"),
	FConsoleCommandWithWorldArgsAndOutputDeviceDelegate::CreateLambda(