Destruction of UObjects

Hi there,

A simple question.

I’ve using ConstructObject to create a UObject class.

I want to destroy it at a certain point, but I can’t see how to do it. Is there a DestructObject function of some kind? Or is it handled automatically if it is a UPROPERTY and it is set to NULL?


UObjects are garbage collected after the last reference is set to null.

An object can be marked as “Pending Kill” (with MarkPendingKill()) to cause the garbage collector to null any accessible references on the next garbage collection and make FindObject() etc ignore the object.

Actor-derived classes can be explicitly destroyed with DestroyActor(), which essentially works by calling various OnDestroyed() callbacks, removing the actor from the level and calling MarkPendingKill() to clean up any references.