Download

UObject and GC safety

Hi,
Is it safe to create UObject in static function, not set to UPROPERTY immediately, set up its properties and then return it to be set to UPROPERTY? Or is UObject in danger of being destroyed during the setting up part? Also is GC determined to run and finish at certain time like before ticking and not in the middle of it?

AFAIK the GC runs on the main thread, so unless you are spawning UObjects on different threads, the UObject won’t have any chance of being garbage collected until at very least the next frame.

Nice. Thank you :slight_smile: