UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GCObjectInfo.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 GarbageCollectionHistory.h: Unreal realtime garbage collection history
5=============================================================================*/
6
7#pragma once
8
9#include "Containers/Map.h"
12#include "HAL/Platform.h"
14#include "Templates/TypeHash.h"
15#include "UObject/Class.h"
17#include "UObject/NameTypes.h"
18#include "UObject/Object.h"
21
28{
29public:
30
31 FGCObjectInfo() = default;
32 explicit FGCObjectInfo(const UObject* Obj)
33 : Name(Obj->GetFName())
34 , Flags(Obj->GetFlags())
35 , InternalFlags(Obj->GetInternalFlags())
36 , ClusterRootIndex(GUObjectArray.ObjectToObjectItem(Obj)->GetOwnerIndex())
37 , bDisregardForGC(GUObjectArray.IsDisregardForGC(Obj))
38 , RefCount(GUObjectArray.ObjectToObjectItem(Obj)->GetRefCount())
39 {
40
41 }
42
43private:
44
46 FName Name;
48 FGCObjectInfo* Class = nullptr;
50 FGCObjectInfo* Outer = nullptr;
56 int32 ClusterRootIndex = -1;
58 bool bDisregardForGC = false;
60 int32 RefCount = 0;
61
62public:
63
69
71 {
72 return Class;
73 }
74
76 {
77 return Outer;
78 }
79
80 inline bool IsIn(const FGCObjectInfo* MaybeOuter) const
81 {
82 for (const FGCObjectInfo* Obj = this; Obj; Obj = Obj->Outer)
83 {
84 if (Obj == MaybeOuter)
85 {
86 return true;
87 }
88 }
89 return false;
90 }
91
93 {
94 return !!(Flags & InFlags);
95 }
96
98 {
99 return !!(InternalFlags & InFlags);
100 }
101
102 bool IsRooted() const
103 {
105 }
106
107 bool IsNative() const
108 {
110 }
111
112 bool IsGarbage() const
113 {
115 }
116
118 {
119 return ClusterRootIndex;
120 }
121
122 FString GetClassName() const
123 {
124 check(Class);
125 return Class->Name.ToString();
126 }
127
129 {
130 return RefCount;
131 }
132
133 bool IsValid() const
134 {
136 }
137
138 bool IsDisregardForGC() const
139 {
140 return bDisregardForGC;
141 }
142
143 COREUOBJECT_API void GetPathName(FStringBuilderBase& ResultString) const;
144 COREUOBJECT_API FString GetPathName() const;
145 COREUOBJECT_API FString GetFullName() const;
146
148 {
149 return HashCombine(GetTypeHash(Info.Outer), GetTypeHash(Info.Name));
150 }
151
154};
#define check(expr)
Definition AssertionMacros.h:314
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
EInternalObjectFlags
Definition ObjectMacros.h:631
@ Garbage
Garbage from logical point of view and should not be referenced. This flag is mirrored in EObjectFlag...
@ Native
Native (UClass only).
@ RootSet
Object will not be garbage collected, even if unreferenced.
EObjectFlags
Definition ObjectMacros.h:552
@ RF_NoFlags
No flags, used to avoid a cast.
Definition ObjectMacros.h:555
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
FUObjectArray GUObjectArray
Definition UObjectHash.cpp:55
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition GCObjectInfo.h:28
bool IsGarbage() const
Definition GCObjectInfo.h:112
int32 GetRefCount() const
Definition GCObjectInfo.h:128
COREUOBJECT_API UObject * TryResolveObject()
Definition GCObjectInfo.cpp:11
friend uint32 GetTypeHash(const FGCObjectInfo &Info)
Definition GCObjectInfo.h:147
static COREUOBJECT_API FGCObjectInfo * FindOrAddInfoHelper(const UObject *InObject, TMap< const UObject *, FGCObjectInfo * > &InOutObjectToInfoMap)
Definition GCObjectInfo.cpp:78
COREUOBJECT_API FString GetPathName() const
Definition GCObjectInfo.cpp:66
FGCObjectInfo * GetClass() const
Definition GCObjectInfo.h:70
bool IsRooted() const
Definition GCObjectInfo.h:102
COREUOBJECT_API FString GetFullName() const
Definition GCObjectInfo.cpp:73
FGCObjectInfo(const UObject *Obj)
Definition GCObjectInfo.h:32
FString GetClassName() const
Definition GCObjectInfo.h:122
bool IsIn(const FGCObjectInfo *MaybeOuter) const
Definition GCObjectInfo.h:80
FGCObjectInfo * GetOuter() const
Definition GCObjectInfo.h:75
bool IsNative() const
Definition GCObjectInfo.h:107
bool IsValid() const
Definition GCObjectInfo.h:133
bool HasAnyInternalFlags(EInternalObjectFlags InFlags) const
Definition GCObjectInfo.h:97
FGCObjectInfo()=default
bool HasAnyFlags(EObjectFlags InFlags) const
Definition GCObjectInfo.h:92
bool IsDisregardForGC() const
Definition GCObjectInfo.h:138
int32 GetOwnerIndex() const
Definition GCObjectInfo.h:117
Definition NameTypes.h:617
Definition UnrealString.h.inl:34
Definition Object.h:95