UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FGCObject Class Referenceabstract

#include <GCObject.h>

+ Inheritance diagram for FGCObject:

Public Types

enum class  EFlags : uint32 { None = 0 , RegisterLater = 1 << 0 , AddStableNativeReferencesOnly = 1 << 1 }
 

Public Member Functions

 FGCObject ()
 
 FGCObject (const FGCObject &Other)
 
 FGCObject (FGCObject &&Other)
 
 FGCObject (EFlags Flags)
 
virtual ~FGCObject ()
 
FGCObjectoperator= (const FGCObject &)
 
FGCObjectoperator= (FGCObject &&)
 
COREUOBJECT_API void RegisterGCObject ()
 
COREUOBJECT_API void UnregisterGCObject ()
 
virtual void AddReferencedObjects (FReferenceCollector &Collector)=0
 
virtual FString GetReferencerName () const =0
 
virtual bool GetReferencerPropertyName (UObject *Object, FString &OutPropertyName) const
 

Static Public Member Functions

static COREUOBJECT_API void StaticInit ()
 

Static Public Attributes

static COREUOBJECT_API UGCObjectReferencerGGCObjectReferencer = nullptr
 

Detailed Description

This class provides common registration for garbage collection for non-UObject classes. It is an abstract base class requiring you to implement the AddReferencedObjects() method.

Note: FGCObject instances are not trivially relocatable, and are therefore not suited for being stored in Unreal container types by value. For example, this won't work: class FMyClass : public FGCObject {}; struct FSomeStruct { TArray<FMyClass> Instances; // Storing anything here might crash GC at // reachability analysis };

Member Enumeration Documentation

◆ EFlags

enum class FGCObject::EFlags : uint32
strong
Enumerator
None 
RegisterLater 

Manually call RegisterGCObject() later to avoid collecting references from empty / late-initialized FGCObjects

AddStableNativeReferencesOnly 

Declare that AddReferencedObjects only calls FReferenceCollector::AddStableReference*() functions instead of the older FReferenceCollector::AddReferenceObject*() and only adds native references.

Allows gathering initial references before reachability analysis starts.

Constructor & Destructor Documentation

◆ FGCObject() [1/4]

FGCObject::FGCObject ( )
inline

Tells the global object that forwards AddReferencedObjects calls on to objects that a new object is requiring AddReferencedObjects call.

◆ FGCObject() [2/4]

FGCObject::FGCObject ( const FGCObject Other)
inline

◆ FGCObject() [3/4]

FGCObject::FGCObject ( FGCObject &&  Other)
inline

◆ FGCObject() [4/4]

FGCObject::FGCObject ( EFlags  Flags)
inlineexplicit

◆ ~FGCObject()

virtual FGCObject::~FGCObject ( )
inlinevirtual

Member Function Documentation

◆ AddReferencedObjects()

virtual void FGCObject::AddReferencedObjects ( FReferenceCollector Collector)
pure virtual

Pure virtual that must be overloaded by the inheriting class. Use this method to serialize any UObjects contained that you wish to keep around.

Parameters
CollectorThe collector of referenced objects.

Implemented in Audio::FMixerDevice, Audio::FSoundSourceDecoder, FARSupportInterface, FAsyncPackage, PackageReloadInternal::FExistingPackageReferences, PackageReloadInternal::FNewPackageReferences, ConstructorHelpers::FObjectFinder< T >, ConstructorHelpers::FObjectFinderOptional< T >, ConstructorHelpers::FClassFinder< T >, TGCObjectScopeGuard< ObjectType >, TGCObjectsScopeGuard< ObjectType >, FStreamableManager, FParticleSystemWorldManager, Audio::FSoundWavePCMLoader, FTextRenderComponentMIDCache, FChaosDerivedDataCookerRefHolder, FPendingStreamingLevelHolder, FSMInstanceElementIdMap, FRepLayout, FPreviewScene, FDebugCanvasDrawer, FDeferredCleanupSlateBrush, FSlateGameResources, FSubsystemCollection< TBaseType >, FSubsystemCollection< UAudioEngineSubsystem >, FViewport::FHitProxyMap, UE::Dataflow::FContextAssetStore, UE::Dataflow::TContextCacheElementUObject< T >, UE::Dataflow::TContextCacheElementUObjectArray< T >, UE::Dataflow::FContextCacheElementUStruct, UE::Dataflow::FContextCacheElementUStructArray, UE::Interchange::FImportResult, UE::Interchange::FImportAsyncHelper, FMassEntityManager, FMassProcessingPhaseManager, FPreLoadSettingsContainerBase, FLegacySlateFontInfoCache, FSlateInvalidationRoot, FStandaloneCompositeFont, FSlateDrawBuffer, FRetainerWidgetRenderingResources, SMeshWidget, FUMGDragDropOp, UE::UniversalObjectLocator::FRegistry, FDefaultWebBrowserAdapter, and FWebJSScripting.

◆ GetReferencerName()

virtual FString FGCObject::GetReferencerName ( ) const
pure virtual

◆ GetReferencerPropertyName()

virtual bool FGCObject::GetReferencerPropertyName ( UObject Object,
FString &  OutPropertyName 
) const
inlinevirtual

Overload this method to report how the specified object is referenced, if necessary

Reimplemented in FStreamableManager.

◆ operator=() [1/2]

FGCObject & FGCObject::operator= ( const FGCObject )
inline

◆ operator=() [2/2]

FGCObject & FGCObject::operator= ( FGCObject &&  )
inline

◆ RegisterGCObject()

void FGCObject::RegisterGCObject ( )

Register with GC, only needed if constructed with EFlags::RegisterLater or after unregistering

◆ StaticInit()

UE_AUTORTFM_ALWAYS_OPEN void FGCObject::StaticInit ( )
static

Initializes the global object referencer and adds it to the root set.

◆ UnregisterGCObject()

void FGCObject::UnregisterGCObject ( )

Unregister ahead of destruction. Safe to call multiple times.

Member Data Documentation

◆ GGCObjectReferencer

UGCObjectReferencer * FGCObject::GGCObjectReferencer = nullptr
static

The static object referencer object that is shared across all garbage collectible non-UObject objects.


The documentation for this class was generated from the following files: