UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GarbageCollectionVerification.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4 GarbageCollectionVerification.h: Unreal realtime garbage collection helpers
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
10#include "Stats/Stats.h"
12#include "UObject/Class.h"
13
14// UE_BUILD_SHIPPING has GShouldVerifyGCAssumptions=false by default
15#define VERIFY_DISREGARD_GC_ASSUMPTIONS !(UE_BUILD_SHIPPING)
16
17#if VERIFY_DISREGARD_GC_ASSUMPTIONS
18
21
24
27
30
31#endif // VERIFY_DISREGARD_GC_ASSUMPTIONS
32
33
34#define PROFILE_GCConditionalBeginDestroy 0
35#define PROFILE_GCConditionalBeginDestroyByClass 0
36
37#if PROFILE_GCConditionalBeginDestroy
38
39struct FCBDTime
40{
41 double TotalTime;
42 int32 Items;
43 FCBDTime()
44 : TotalTime(0.0)
45 , Items(0)
46 {
47 }
48
49 bool operator<(const FCBDTime& Other) const
50 {
51 return TotalTime > Other.TotalTime;
52 }
53};
54
57
59{
60 FName Obj;
61 double StartTime;
62
64 : StartTime(FPlatformTime::Seconds())
65 {
66 CBDNameLookup.Add(InObj, InObj->GetFName());
67#if PROFILE_GCConditionalBeginDestroyByClass
68 UObject* Outermost = ((UObject*)InObj->GetClass());
69#else
70 UObject* Outermost = ((UObject*)InObj->GetOutermost());
71#endif
72 Obj = Outermost->GetFName();
73 if (Obj == NAME_None)
74 {
75 Obj = CBDNameLookup.FindRef(Outermost);
76 }
77 }
79 {
80 double ThisTime = FPlatformTime::Seconds() - StartTime;
81 FCBDTime& Rec = CBDTimings.FindOrAdd(Obj);
82 Rec.Items++;
83 Rec.TotalTime += ThisTime;
84 }
85 static void DumpProfile();
86};
87
88
89#else
91{
96 {
97 }
98};
99#endif
#define FORCEINLINE
Definition AndroidPlatform.h:140
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
void VerifyGCAssumptions()
void VerifyClustersAssumptions()
void VerifyNoUnreachableObjects(int32 NumUnreachable)
void VerifyObjectFlags()
bool operator<(const FTextFormatString &LHS, const FTextFormatString &RHS)
Definition ITextFormatArgumentModifier.h:147
Definition NameTypes.h:617
Definition UnrealString.h.inl:34
COREUOBJECT_API UPackage * GetOutermost() const
Definition UObjectBaseUtility.cpp:224
FORCEINLINE FName GetFName() const
Definition UObjectBase.h:233
FORCEINLINE UClass * GetClass() const
Definition UObjectBase.h:217
Definition Object.h:95
Definition AndroidPlatformTime.h:18
static double Seconds()
Definition AndroidPlatformTime.h:20
Definition GarbageCollectionVerification.h:91
static FORCEINLINE void DumpProfile()
Definition GarbageCollectionVerification.h:95
FORCEINLINE FScopedCBDProfile(UObject *)
Definition GarbageCollectionVerification.h:92