How to properly work with UObjects in background threads (GC)
This short article addresses the question of how to work with UObjects in a thread-safe way when passing them to some workers, asynchronous tasks, thread pools, or whatever else using a non-game thread. One of the crucial issues is garbage collection. When we pass a UObject that is not set to root directly to a background thread, it’s possible that the garbage collector may silently delete the passed UObject. Even if we frequently check the validity of the UObject (IsValidLowLevel()) on a background thread, we cannot guarantee that this object will remain alive, even just a few milliseconds after the check....