UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GarbageCollection.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 GarbageCollection.h: Unreal realtime garbage collection helpers
5=============================================================================*/
6
7#pragma once
8
10#include "CoreTypes.h"
11#include "Logging/LogMacros.h"
13#include "Stats/Stats.h"
16#include "UObject/UnrealNames.h"
17
18class UObject;
19
20#if WITH_VERSE_VM || defined(__INTELLISENSE__)
21namespace Verse
22{
23struct VNativeStruct;
24}
25#endif
26
28#define GARBAGE_COLLECTION_KEEPFLAGS (GIsEditor ? RF_Standalone : RF_NoFlags)
29
31#ifndef ENABLE_GC_OBJECT_CHECKS
32 #define ENABLE_GC_OBJECT_CHECKS (!(UE_BUILD_TEST || UE_BUILD_SHIPPING) || 0)
33#endif
34
35#define ENABLE_GC_HISTORY (!UE_BUILD_SHIPPING)
36
39
44#define DO_POINTER_CHECKS_ON_GC 0
45
46
47namespace UE::GC
48{
49
50enum class EAROFlags
51{
52 None = 0,
53 Unbalanced = 1 << 0, // Some instances are very slow but most are fast. GC can flush these more frequently.
54 ExtraSlow = 2 << 0, // All instances are slow. GC can work-steal these at finer batch granularity.
55};
57
58// Reference collection batches up slow AddReferencedObjects calls
60
61class FSchemaView;
62
65{
66public:
67 FSchemaOwner() = default;
68 FSchemaOwner(const FSchemaOwner&) = delete;
69 FSchemaOwner(FSchemaOwner&& In) : SchemaView(In.SchemaView) { In.SchemaView = 0; }
74 {
75 Reset();
76 Swap(In.SchemaView, SchemaView);
77 return *this;
78 }
79
81 const FSchemaView& Get() const { return reinterpret_cast<const FSchemaView&>(SchemaView); }
83private:
84 uint64 SchemaView = 0;
85};
86
87#if WITH_VERSE_VM || defined(__INTELLISENSE__)
93COREUOBJECT_API void EnableFrankenGCMode(bool bEnable);
94
99
102
106COREUOBJECT_API void MarkNativeStructAsReachable(::Verse::VNativeStruct* NativeStruct);
107#endif
108
109} // namespace UE::GC
110
118
120{
121public:
124
125 bool LockSucceeded() const { return bLockSuccessful;}
126
127private:
128 bool bLockSuccessful = false;
129};
130
131class FGCObject;
132
168
178
181
188
195
203
208
209namespace UE::GC::Private
210{
211 COREUOBJECT_API void SetSkipDestroy(bool bSkip);
212}
#define TSAN_ATOMIC(Type)
Definition CoreMiscDefines.h:147
#define TEXT(x)
Definition Platform.h:1272
#define UE_FORCEINLINE_HINT
Definition Platform.h:723
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
#define DECLARE_STATS_GROUP(GroupDesc, GroupId, GroupCat)
Definition Stats.h:689
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
return true
Definition ExternalRpcRegistry.cpp:601
UE_FORCEINLINE_HINT bool IsGarbageCollecting()
Definition GarbageCollection.h:199
COREUOBJECT_API double GetLastGCTime()
Definition GarbageCollection.cpp:6080
COREUOBJECT_API bool IsGarbageCollectingAndLockingUObjectHashTables()
Definition GarbageCollection.cpp:5119
COREUOBJECT_API double GetLastGCDuration()
Definition GarbageCollection.cpp:6085
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
Definition GCObject.h:128
Definition GarbageCollection.h:113
COREUOBJECT_API ~FGCScopeGuard()
Definition GarbageCollection.cpp:210
COREUOBJECT_API FGCScopeGuard()
Definition GarbageCollection.cpp:194
Definition GarbageCollection.h:120
COREUOBJECT_API ~FGCScopeTryGuard()
Definition GarbageCollection.cpp:220
COREUOBJECT_API FGCScopeTryGuard()
Definition GarbageCollection.cpp:215
bool LockSucceeded() const
Definition GarbageCollection.h:125
Definition NameTypes.h:617
Definition UObjectGlobals.h:2492
Definition GarbageCollection.h:65
const FSchemaView & Get() const
Definition GarbageCollection.h:81
FSchemaOwner(FSchemaOwner &&In)
Definition GarbageCollection.h:69
FSchemaOwner(const FSchemaOwner &)=delete
FSchemaOwner & operator=(FSchemaOwner &&In)
Definition GarbageCollection.h:73
FSchemaOwner & operator=(const FSchemaOwner &)=delete
~FSchemaOwner()
Definition GarbageCollection.h:71
COREUOBJECT_API void Reset()
Definition GarbageCollectionSchema.cpp:201
Definition GarbageCollectionSchema.h:115
Definition Object.h:95
Definition GarbageCollection.cpp:624
void SetSkipDestroy(bool bSkip)
Definition GarbageCollection.cpp:647
Definition GCObjectReferencer.cpp:27
void RegisterSlowImplementation(ObjectAROFn ARO, EAROFlags Flags)
Definition GarbageCollection.cpp:2881
EAROFlags
Definition GarbageCollection.h:51
Definition Archive.h:36
@ false
Definition radaudio_common.h:23
Definition GarbageCollection.h:170
FGCDirectReference(const Verse::VCell *Cell, FName Name=NAME_None)
Definition GarbageCollection.h:173
FName ReferencerName
Definition GarbageCollection.h:175
FReferenceToken Reference
Definition GarbageCollection.h:176
FGCDirectReference(const UObject *Obj, FName Name=NAME_None)
Definition GarbageCollection.h:172
FGCDirectReference(FReferenceToken InReference, FName Name=NAME_None)
Definition GarbageCollection.h:171
Definition GarbageCollection.h:135
FGarbageReferenceInfo(FGCObject *InReferencingObject, UObject *InGarbageObject)
Definition GarbageCollection.h:158
FGarbageReferenceInfo(const UObject *InReferencingObject, UObject *InGarbageObject, FName InPropertyName)
Definition GarbageCollection.h:151
FName PropertyName
Definition GarbageCollection.h:149
bool bReferencerUObject
Definition GarbageCollection.h:147
UObject * GarbageObject
Definition GarbageCollection.h:137
union FGarbageReferenceInfo::FReferencerUnion Referencer
FString GetReferencingObjectInfo() const
Definition GarbageCollection.cpp:6063
Definition ReferenceToken.h:44
Definition GarbageCollection.h:140
const UObject * Object
Definition GarbageCollection.h:142
FGCObject * GCObject
Definition GarbageCollection.h:144