UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InheritedContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
8
9namespace UE
10{
11#if ENABLE_LOW_LEVEL_MEM_TRACKER
14 {
16 const UE::LLMPrivate::FTagData* LLMTags[static_cast<uint32>(ELLMTagSet::Max)];
17
19 {
21 {
22 LLMTags[TagSetIndex] = FLowLevelMemTracker::IsEnabled() ?
23 FLowLevelMemTracker::Get().GetActiveTagData(ELLMTracker::Default, static_cast<ELLMTagSet>(TagSetIndex))
24 : nullptr;
25 }
26 }
27 };
28
31 {
35
37 {
39 }
40
42 {
44 {
45 LLMScopes.Emplace(InActiveTagsCapture.LLMTags[TagSetIndex], false /* bIsStatTag */, static_cast<ELLMTagSet>(TagSetIndex), ELLMTracker::Default);
46 }
47 }
48 };
49#endif
50
51 // Restores an inherited contex for the current scope.
52 // An instance must be obtained by calling `FInheritedContextBase::RestoreInheritedContext()`
54 {
55 private:
57
58 friend class FInheritedContextBase; // allow construction only by `FInheritedContextBase`
59
64 ,
65 #endif
66#endif
70 ,
71 #endif
72#endif
75#endif
76 )
77#if ENABLE_LOW_LEVEL_MEM_TRACKER
79 #if UE_TRACE_ENABLED && (UE_MEMORY_TAGS_TRACE_ENABLED || UE_TRACE_METADATA_ENABLED)
80 ,
81 #endif
82#endif
83#if (UE_MEMORY_TAGS_TRACE_ENABLED && UE_TRACE_ENABLED)
84 #if !ENABLE_LOW_LEVEL_MEM_TRACKER
85 :
86 #endif
88 #if (UE_TRACE_METADATA_ENABLED && UE_TRACE_ENABLED)
89 ,
90 #endif
91#endif
92#if (UE_TRACE_METADATA_ENABLED && UE_TRACE_ENABLED)
93 #if !ENABLE_LOW_LEVEL_MEM_TRACKER && !(UE_MEMORY_TAGS_TRACE_ENABLED && UE_TRACE_ENABLED)
94 :
95 #endif
97#endif
98 {
99 }
100
101 private:
102#if ENABLE_LOW_LEVEL_MEM_TRACKER
104#endif
105
106#if (UE_MEMORY_TAGS_TRACE_ENABLED && UE_TRACE_ENABLED)
108#endif
109
110#if (UE_TRACE_METADATA_ENABLED && UE_TRACE_ENABLED)
112#endif
113 };
114
115 // this class extends the inherited context (see private members for what the inherited context is) to cover async execution.
116 // Is intended to be used as a base class, if the inherited context is compiled out it takes 0 space
118 {
119 public:
120 // must be called in the inherited context, e.g. on launching an async task
122 {
123#if ENABLE_LOW_LEVEL_MEM_TRACKER
124 InheritedLLMTags.CaptureActiveTagData();
125#endif
126
127#if UE_MEMORY_TAGS_TRACE_ENABLED && UE_TRACE_ENABLED
129#endif
130
131#if UE_TRACE_METADATA_ENABLED && UE_TRACE_ENABLED
133#endif
134 }
135
136 // must be called where the inherited context should be restored, e.g. at the start of an async task execution
138
139 private:
140#if ENABLE_LOW_LEVEL_MEM_TRACKER
142#endif
143
144#if UE_MEMORY_TAGS_TRACE_ENABLED && UE_TRACE_ENABLED
146#endif
147
148#if UE_TRACE_METADATA_ENABLED && UE_TRACE_ENABLED
150#endif
151 };
152}
#define UE_TRACE_ENABLED
Definition Config.h:21
#define UE_NONCOPYABLE(TypeName)
Definition CoreMiscDefines.h:457
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENABLE_LOW_LEVEL_MEM_TRACKER
Definition LowLevelMemTracker.h:20
#define UE_TRACE_METADATA_SAVE_STACK()
Definition MetadataTrace.h:104
#define UE_TRACE_METADATA_ENABLED
Definition MetadataTrace.h:10
int32 MemoryTrace_GetActiveTag()
Definition TagTrace.cpp:436
#define UE_MEMORY_TAGS_TRACE_ENABLED
Definition TagTrace.h:30
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition InheritedContext.h:118
CORE_API FInheritedContextScope RestoreInheritedContext()
Definition InheritedContext.cpp:8
void CaptureInheritedContext()
Definition InheritedContext.h:121
Definition InheritedContext.h:54
Definition AdvancedWidgetsModule.cpp:13