How to release an object that is New in C++?

1 Like

it’s in Unreal’s normal life cycle so a destroy command should probably be sufficient.

In this case:
Channel1LoginInfo->DestroyComponent();

If you component requires some internal cleanup then you can override BeginDestroy()

You can call MarkAsGarbage() (UE5) or MarkPendingKill() (UE4). The garbage collector will pick this up on the next GC run and will try to destroy it.

It looks like in this case, you’re creating the object on the stack and nothing is referencing it to keep it alive - therefore this process will happen automatically and you don’t need to do anything.

1 Like