While investigating memory issues, I find that Unreal will not automatically unload/destroy “unused” Assets(like StaticMesh). I found such behaviours in these 2 cases:
- double clicking a static mesh asset in content browser, then close the mesh editor, “obj gc” several times
- double click and open a Level, after it’s loaded, double click another Level that is empty
I confirmed StaticMesh not unloaded/destroyed by using obj list and obj refs, for those objects that I think should be cleaned up, it(obj refs) says
LogReferenceChain: (standalone) FoliageType_InstancedStaticMesh /Game/Scene/External/BlackAlder/Foliage/SimpleWind/FT_BlackAlder_Field_03.FT_BlackAlder_Field_03 is not currently reachable but it does have some of GARBAGE_COLLECTION_KEEPFLAGS set.
Browsing through code, I find that CollectGarbages() is usually called in editor with GARBAGE_COLLECTION_KEEPFLAGS which in Editor is RF_Standalone.
So here’s my question: Why is this the default behaviour? Doesn’t that means Assets would be kept alive and the memory will keeps growing? Are there any console commands that would allow a call to CollectGarbages(RF_NoFlags)?