UObject
s are reference-counted and garbage-collected when there are no more references to the UObject
instance. Memory allocated on a UObject
class derivative using ConstructObject<>
or NewObject< >
can also be deallocated manually (before the reference count drops to 0) by calling the UObject::ConditionalBeginDestroy()
member function.
You'd only do this if you were sure you no longer wanted UObject
or the UObject
class derivative instance in memory. Use the ConditionalBeginDestroy()
function to release memory.
The following code demonstrates the deallocation of a UObject class
:
UObject *o = NewObject< UObject >( ... ); o->ConditionalBeginDestroy();