What's the best way to force garbage collection?

I’ve added a check in UObjectBasUtility::AddToRoot() and that finally solved the mystery.

The object is rooted during the FUObjectArray::CloseDisregardForGC() call in FEngineLoop::PreInitPostStartupScreen().

The “Disregard for GC” set is a list of all UObjects that are created during Engine startup, especially in CDO (ClassDefaultObject) constructors, but it also includes objects created in any other way during startup.

The assumption is that any objects created that early or in a CDO need to be kept alive for the whole lifetime of the application, since CDOs itself also never get destroyed.

I think in this specific case it’s ok to remove the object from the root set, since the lifetime is managed by the FContentBrowserAssetDataSourceModule and quite clear (even if the StrongObjectPtr is essentially useless due to the object being rooted anyway).

Best,

Sebastian