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

#include <UObjectArray.h>

Classes

class  FUObjectCreateListener
 
class  FUObjectDeleteListener
 
class  TIterator
 

Public Types

enum  ESerialNumberConstants { START_SERIAL_NUMBER = 1000 }
 

Public Member Functions

COREUOBJECT_API FUObjectArray ()
 
COREUOBJECT_API void AllocateObjectPool (int32 MaxUObjects, int32 MaxObjectsNotConsideredByGC, bool bPreAllocateObjectArray)
 
COREUOBJECT_API void DisableDisregardForGC ()
 
COREUOBJECT_API void OpenDisregardForGC ()
 
COREUOBJECT_API void CloseDisregardForGC ()
 
bool IsOpenForDisregardForGC () const
 
bool DisregardForGCEnabled () const
 
COREUOBJECT_API void AllocateUObjectIndex (class UObjectBase *Object, EInternalObjectFlags InitialFlags, int32 AlreadyAllocatedIndex=-1, int32 SerialNumber=0, FRemoteObjectId RemoteId=FRemoteObjectId())
 
COREUOBJECT_API void FreeUObjectIndex (class UObjectBase *Object)
 
UE_FORCEINLINE_HINT int32 ObjectToIndex (const class UObjectBase *Object) const
 
FUObjectItemIndexToObject (int32 Index)
 
UE_FORCEINLINE_HINT FUObjectItemIndexToObjectUnsafeForGC (int32 Index)
 
FUObjectItemIndexToObject (int32 Index, bool bEvenIfGarbage)
 
FUObjectItemObjectToObjectItem (const UObjectBase *Object)
 
bool IsValid (FUObjectItem *ObjectItem, bool bEvenIfGarbage)
 
FUObjectItemIndexToValidObject (int32 Index, bool bEvenIfGarbage)
 
bool IsValid (int32 Index, bool bEvenIfGarbage)
 
UE_FORCEINLINE_HINT bool IsStale (FUObjectItem *ObjectItem, bool bIncludingGarbage)
 
bool IsStale (int32 Index, bool bIncludingGarbage)
 
UE_FORCEINLINE_HINT int32 GetFirstGCIndex () const
 
COREUOBJECT_API void AddUObjectCreateListener (FUObjectCreateListener *Listener)
 
COREUOBJECT_API void RemoveUObjectCreateListener (FUObjectCreateListener *Listener)
 
COREUOBJECT_API void AddUObjectDeleteListener (FUObjectDeleteListener *Listener)
 
COREUOBJECT_API void RemoveUObjectDeleteListener (FUObjectDeleteListener *Listener)
 
COREUOBJECT_API void RemoveObjectFromDeleteListeners (UObjectBase *Object)
 
COREUOBJECT_API bool IsValid (const UObjectBase *Object) const
 
UE_FORCEINLINE_HINT bool IsValidIndex (const UObjectBase *Object) const
 
UE_FORCEINLINE_HINT bool IsIndexDisregardForGC (int32 ObjectIndex) const
 
UE_FORCEINLINE_HINT bool IsDisregardForGC (const class UObjectBase *Object) const
 
UE_FORCEINLINE_HINT int32 GetObjectArrayNum () const
 
UE_FORCEINLINE_HINT int32 GetObjectArrayNumMinusPermanent () const
 
UE_FORCEINLINE_HINT int32 GetObjectArrayNumPermanent () const
 
int32 GetObjectArrayNumMinusAvailable () const
 
int32 GetObjectArrayEstimatedAvailable () const
 
int32 GetObjectArrayCapacity () const
 
COREUOBJECT_API void ShutdownUObjectArray ()
 
COREUOBJECT_API int32 AllocateSerialNumber (int32 Index)
 
int32 GetSerialNumber (int32 Index)
 
void LockInternalArray () const
 
void UnlockInternalArray () const
 
void LockUObjectDeleteListeners ()
 
void UnlockUObjectDeleteListeners ()
 
TUObjectArrayGetObjectItemArrayUnsafe ()
 
const TUObjectArrayGetObjectItemArrayUnsafe () const
 
SIZE_T GetAllocatedSize () const
 
SIZE_T GetDeleteListenersAllocatedSize (int32 *OutNumListeners=nullptr) const
 
COREUOBJECT_API void DumpUObjectCountsToLog () const
 

Friends

class UObject
 
COREUOBJECT_API UObjectStaticAllocateObject (const UClass *, UObject *, FName, EObjectFlags, EInternalObjectFlags, bool, bool *, UPackage *, int32, FRemoteObjectId, class FGCReconstructionGuard *)
 

Member Enumeration Documentation

◆ ESerialNumberConstants

Enumerator
START_SERIAL_NUMBER 

Constructor & Destructor Documentation

◆ FUObjectArray()

FUObjectArray::FUObjectArray ( )

Constructor, initializes to no permanent object pool

Member Function Documentation

◆ AddUObjectCreateListener()

void FUObjectArray::AddUObjectCreateListener ( FUObjectCreateListener Listener)

Adds a new listener for object creation

Parameters
Listenerlistener to notify when an object is deleted

Adds a creation listener

Parameters
Listenerlistener to notify when an object is deleted

◆ AddUObjectDeleteListener()

void FUObjectArray::AddUObjectDeleteListener ( FUObjectDeleteListener Listener)

Adds a new listener for object deletion

Parameters
Listenerlistener to notify when an object is deleted

Checks whether object is part of permanent object pool.

Parameters
Listenerlistener to notify when an object is deleted

◆ AllocateObjectPool()

void FUObjectArray::AllocateObjectPool ( int32  MaxUObjects,
int32  MaxObjectsNotConsideredByGC,
bool  bPreAllocateObjectArray 
)

Allocates and initializes the permanent object pool

Parameters
MaxUObjectsmaximum number of UObjects that can ever exist in the array
MaxObjectsNotConsideredByGCnumber of objects in the permanent object pool

◆ AllocateSerialNumber()

int32 FUObjectArray::AllocateSerialNumber ( int32  Index)

Given a UObject index return the serial number. If it doesn't have a serial number, give it one. Threadsafe.

Parameters
Index- UObject Index
Returns
- the serial number for this UObject

◆ AllocateUObjectIndex()

void FUObjectArray::AllocateUObjectIndex ( class UObjectBase Object,
EInternalObjectFlags  InitialFlags,
int32  AlreadyAllocatedIndex = -1,
int32  SerialNumber = 0,
FRemoteObjectId  RemoteId = FRemoteObjectId() 
)

Adds a uobject to the global array which is used for uobject iteration

Parameters
ObjectObject to allocate an index for
InitialFlagsFlags to set in the object array before the object pointer becomes visible to other threads.
AlreadyAllocatedIndexalready allocated internal index to use, negative value means allocate a new index
SerialNumberserial number to use

◆ CloseDisregardForGC()

void FUObjectArray::CloseDisregardForGC ( )

After the initial load, this closes the disregard pool so that new object are GC-able

◆ DisableDisregardForGC()

void FUObjectArray::DisableDisregardForGC ( )

Disables the disregard for GC optimization.

◆ DisregardForGCEnabled()

bool FUObjectArray::DisregardForGCEnabled ( ) const
inline

indicates if the disregard for GC optimization is active

Returns
true if MaxObjectsNotConsideredByGC is greater than zero; this indicates that the disregard for GC optimization is enabled

◆ DumpUObjectCountsToLog()

void FUObjectArray::DumpUObjectCountsToLog ( ) const

◆ FreeUObjectIndex()

void FUObjectArray::FreeUObjectIndex ( class UObjectBase Object)

Returns a UObject index top to the global uobject array

Parameters
Objectobject to free

Returns a UObject index to the global uobject array

Parameters
Objectobject to free

◆ GetAllocatedSize()

SIZE_T FUObjectArray::GetAllocatedSize ( ) const
inline

◆ GetDeleteListenersAllocatedSize()

SIZE_T FUObjectArray::GetDeleteListenersAllocatedSize ( int32 OutNumListeners = nullptr) const
inline

◆ GetFirstGCIndex()

UE_FORCEINLINE_HINT int32 FUObjectArray::GetFirstGCIndex ( ) const
inline

Returns the index of the first object outside of the disregard for GC pool

◆ GetObjectArrayCapacity()

int32 FUObjectArray::GetObjectArrayCapacity ( ) const
inline

Returns the estimated number of object indices available for allocation

◆ GetObjectArrayEstimatedAvailable()

int32 FUObjectArray::GetObjectArrayEstimatedAvailable ( ) const
inline

Returns the estimated number of object indices available for allocation

◆ GetObjectArrayNum()

UE_FORCEINLINE_HINT int32 FUObjectArray::GetObjectArrayNum ( ) const
inline

Returns the size of the global UObject array, some of these might be unused

Returns
the number of UObjects in the global array

◆ GetObjectArrayNumMinusAvailable()

int32 FUObjectArray::GetObjectArrayNumMinusAvailable ( ) const
inline

Returns the number of actual object indices that are claimed (the total size of the global object array minus the number of available object array elements

Returns
The number of objects claimed

◆ GetObjectArrayNumMinusPermanent()

UE_FORCEINLINE_HINT int32 FUObjectArray::GetObjectArrayNumMinusPermanent ( ) const
inline

Returns the size of the global UObject array minus the number of permanent objects

Returns
the number of UObjects in the global array

◆ GetObjectArrayNumPermanent()

UE_FORCEINLINE_HINT int32 FUObjectArray::GetObjectArrayNumPermanent ( ) const
inline

Returns the number of permanent objects

Returns
the number of permanent objects

◆ GetObjectItemArrayUnsafe() [1/2]

TUObjectArray & FUObjectArray::GetObjectItemArrayUnsafe ( )
inline

INTERNAL USE ONLY: gets the internal FUObjectItem array

◆ GetObjectItemArrayUnsafe() [2/2]

const TUObjectArray & FUObjectArray::GetObjectItemArrayUnsafe ( ) const
inline

◆ GetSerialNumber()

int32 FUObjectArray::GetSerialNumber ( int32  Index)
inline

Given a UObject index return the serial number. If it doesn't have a serial number, return 0. Threadsafe.

Parameters
Index- UObject Index
Returns
- the serial number for this UObject

◆ IndexToObject() [1/2]

FUObjectItem * FUObjectArray::IndexToObject ( int32  Index)
inline

Returns the UObject corresponding to index. Be advised this is only for very low level use.

Parameters
Indexindex of object to return
Returns
Object at this index

◆ IndexToObject() [2/2]

FUObjectItem * FUObjectArray::IndexToObject ( int32  Index,
bool  bEvenIfGarbage 
)
inline

◆ IndexToObjectUnsafeForGC()

UE_FORCEINLINE_HINT FUObjectItem * FUObjectArray::IndexToObjectUnsafeForGC ( int32  Index)
inline

◆ IndexToValidObject()

FUObjectItem * FUObjectArray::IndexToValidObject ( int32  Index,
bool  bEvenIfGarbage 
)
inline

◆ IsDisregardForGC()

UE_FORCEINLINE_HINT bool FUObjectArray::IsDisregardForGC ( const class UObjectBase Object) const
inline

Returns true if this object is "disregard for GC"...same results as the legacy RF_DisregardForGC flag

Parameters
Objectobject to get for disregard for GC
Returns
true if this object is disregard for GC

◆ IsIndexDisregardForGC()

UE_FORCEINLINE_HINT bool FUObjectArray::IsIndexDisregardForGC ( int32  ObjectIndex) const
inline

Returns true if this object index is "disregard for GC"

Parameters
Indexobject index to get for disregard for GC
Returns
true if this object index is disregard for GC

◆ IsOpenForDisregardForGC()

bool FUObjectArray::IsOpenForDisregardForGC ( ) const
inline

Returns true if the disregard for GC pool is open

◆ IsStale() [1/2]

UE_FORCEINLINE_HINT bool FUObjectArray::IsStale ( FUObjectItem ObjectItem,
bool  bIncludingGarbage 
)
inline

◆ IsStale() [2/2]

bool FUObjectArray::IsStale ( int32  Index,
bool  bIncludingGarbage 
)
inline

◆ IsValid() [1/3]

bool FUObjectArray::IsValid ( const UObjectBase Object) const

Checks if a UObject pointer is valid

Parameters
Objectobject to test for validity
Returns
true if this index is valid

Checks if a UObject index is valid

Parameters
Objectobject to test for validity
Returns
true if this index is valid

◆ IsValid() [2/3]

bool FUObjectArray::IsValid ( FUObjectItem ObjectItem,
bool  bEvenIfGarbage 
)
inline

◆ IsValid() [3/3]

bool FUObjectArray::IsValid ( int32  Index,
bool  bEvenIfGarbage 
)
inline

◆ IsValidIndex()

UE_FORCEINLINE_HINT bool FUObjectArray::IsValidIndex ( const UObjectBase Object) const
inline

Checks if the object index is valid.

◆ LockInternalArray()

void FUObjectArray::LockInternalArray ( ) const
inline

Locks the internal object array mutex

◆ LockUObjectDeleteListeners()

void FUObjectArray::LockUObjectDeleteListeners ( )
inline

Locks the mutex protecting the list of delete listeners

◆ ObjectToIndex()

UE_FORCEINLINE_HINT int32 FUObjectArray::ObjectToIndex ( const class UObjectBase Object) const
inline

Returns the index of a UObject. Be advised this is only for very low level use.

Parameters
Objectobject to get the index of
Returns
index of this object

◆ ObjectToObjectItem()

FUObjectItem * FUObjectArray::ObjectToObjectItem ( const UObjectBase Object)
inline

◆ OpenDisregardForGC()

void FUObjectArray::OpenDisregardForGC ( )

If there's enough slack in the disregard pool, we can re-open it and keep adding objects to it

◆ RemoveObjectFromDeleteListeners()

void FUObjectArray::RemoveObjectFromDeleteListeners ( UObjectBase Object)

Removes an object from delete listeners

Parameters
Objectto remove from delete listeners

◆ RemoveUObjectCreateListener()

void FUObjectArray::RemoveUObjectCreateListener ( FUObjectCreateListener Listener)

Removes a listener for object creation

Parameters
Listenerlistener to remove

◆ RemoveUObjectDeleteListener()

void FUObjectArray::RemoveUObjectDeleteListener ( FUObjectDeleteListener Listener)

Removes a listener for object deletion

Parameters
Listenerlistener to remove

removes a listener for object deletion

Parameters
Listenerlistener to remove

◆ ShutdownUObjectArray()

void FUObjectArray::ShutdownUObjectArray ( )

Clears some internal arrays to get rid of false memory leaks

◆ UnlockInternalArray()

void FUObjectArray::UnlockInternalArray ( ) const
inline

Unlocks the internal object array mutex

◆ UnlockUObjectDeleteListeners()

void FUObjectArray::UnlockUObjectDeleteListeners ( )
inline

Unlocks the mutex protecting the list of delete listeners

Friends And Related Symbol Documentation

◆ StaticAllocateObject

COREUOBJECT_API UObject * StaticAllocateObject ( const UClass ,
UObject ,
FName  ,
EObjectFlags  ,
EInternalObjectFlags  ,
bool  ,
bool ,
UPackage ,
int32  ,
FRemoteObjectId  ,
class FGCReconstructionGuard  
)
friend

Create a new instance of an object or replace an existing object. If both an Outer and Name are specified, and there is an object already in memory with the same Class, Outer, and Name, the existing object will be destructed, and the new object will be created in its place.

Parameters
Classthe class of the object to create
InOuterthe object to create this object within (the Outer property for the new object will be set to the value specified here).
Namethe name to give the new object. If no value (NAME_None) is specified, the object will be given a unique name in the form of ClassName_#.
SetFlagsthe ObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object.
InternalSetFlagsthe InternalObjectFlags to assign to the new object. some flags can affect the behavior of constructing the object.
bCanReuseSubobjectsif set to true, SAO will not attempt to destroy a subobject if it already exists in memory.
bOutReusedSubobjectflag indicating if the object is a subobject that has already been created (in which case further initialization is not necessary).
ExternalPackageExternal Package assigned to the allocated object, if any
RemoteIdGlobally unique id for this object
GCGuardSpecial synchronization object that prevents GC from running when reconstructing an object on top of existing one
Returns
a pointer to a fully initialized object of the specified class.

◆ UObject

friend class UObject
friend

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