Figure: Diagnostic workflow: Measure load/unload work → Schedule resource cleanup → Compare stalls and memory
Figure: Diagnostic workflow: Measure load/unload work → Schedule resource cleanup → Compare stalls and memory

Cause and mechanism

Loading a scene asynchronously does not move every part of the transition off the main thread, where much of the game runs. Measure scene activation, object creation and destruction, unused-asset scanning, and garbage collection (GC), which reclaims unused managed memory. UnloadSceneAsync alone does not unload the scene's assets.

Check and correct the setup

  1. Profile scene activation, UnloadUnusedAssets, and GC separately on the device.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time
  2. Remove unused references before cleanup, run it during a loading screen, and await its AsyncOperation.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time
  3. Manage Addressables handles and consider incremental GC; avoid repeated forced GC.Collect calls.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time

Limits and verification

An async API does not guarantee all work runs off-thread. Incremental GC does not slice asset cleanup or scene activation; pools increase retained memory.

A focused diagnostic setup

Compare transition into an empty scene with the real heavy scene and locate the hitch during loading, activation or old-scene cleanup.

Test in this order

  1. Inspect the slow frame, separating activation callbacks, unused-asset scanning and GC.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time
  2. Temporarily reduce destination spawning/initialization to test whether it drives the pause.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time
  3. Repeat the same transition to distinguish first-use shader preparation from recurring work and memory retention.
    GC.Alloc ≠ GC time
    GC.Alloc ≠ GC time

Interpret the result

Investigate initialization for activation hitches and references/scanning for cleanup hitches. Manually invoking GC does not reduce unrelated stages. Verify loading-screen responsiveness too.

Related explanations

References