Does cancelling LoadPackageAsync during PostLoad leave asset references in memory?
0 reputation · 04 Mar 2026, 02:47 UTC
When using LoadPackageAsync to stream assets, the engine initiates asynchronous loading and invokes PostLoad on the resulting UObject. If the async operation is cancelled while PostLoad is executing, the engine may retain a reference to the partially or fully loaded object, preventing the garbage collector from reclaiming its memory. This behavior is noted in engine source comments but is not guaranteed to surface in deterministic tests because it depends on timing and the state of the reference‑tracking system.
The goal is to understand whether such retained references persist until the next GC cycle or are leaked indefinitely, and what conditions affect their release. Verification requires repeated load‑cancel cycles and memory profiling, yet results can vary across platforms and engine versions.
Does the engine keep a strong reference to the asset after cancellation during PostLoad? Is that reference cleared automatically by the garbage collector, or does it require explicit invalidation? Are there any reliable work‑arounds besides waiting for GC or avoiding cancellation during PostLoad?