truong-bui / AsyncLoadingScreen

Async Loading Screen is a free and open-source plugin for Unreal Engine. Async Loading Screen allows you to easily configure a Loading Screen System in the project settings, and automatically add a Loading Screen whenever you open a new level, without Level Streaming.
https://www.unrealengine.com/marketplace/en-US/product/async-loading-screen
MIT License
799 stars 99 forks source link

Background images loaded at startup can't be collected by GC afterwards #57

Open Snowball2012 opened 2 years ago

Snowball2012 commented 2 years ago

Hello,

FAsyncLoadingScreenModule::StartupModule calls SetupLoadingScreen(Settings->StartupLoadingScreen) at module startup time. That happens while disregard for gc pool is still open, so all UObjects loaded at this stage (e.g. background textures in SBackgroundWidget) can't be released by gc later and can consume a portion of gpu memory as long as the module is loaded (entire process lifetime basically). This doesn't happen with other loading screens because they are constructed much later, after CloseDisregardForGC is called.

You can see this behaviour if you specify some texture in BackgroundSettings for startup screen and call obj refs name= <TextureName> after the game has loaded. The background texture will be marked as root and thus won't be collected by GC:

(root) (standalone)  MetaData /Game/<TexturePath>
 -> UObject* UObject::Outer = (root)  Package /Game/<TexturePath>