Many Unity projects encounter the same dilemma.
Calling Resources.UnloadUnusedAssets too frequently introduces visible frame stalls, while delaying cleanup allows memory usage to continue growing. This becomes especially challenging in open-world games where seamless streaming removes the natural cleanup opportunities provided by scene transitions.
The first instinct is often to keep adjusting the execution timing. In practice, however, the more important question is whether the cleanup actually releases any assets.
A practical way to verify this is to examine the Asset Count before and after every Resources.UnloadUnusedAssets execution.
- If the Asset Count drops noticeably, the cleanup is working as expected.
- If the curve barely changes, the cleanup likely became an "empty run".
One of the most common reasons is that the corresponding AssetBundle is still loaded. Since the assets remain referenced by the loaded AssetBundle, Unity cannot reclaim them even though Resources.UnloadUnusedAssets executes successfully.
The engine still performs a resource scan, causing additional main-thread work without reducing memory usage.
Because of this, the troubleshooting order is often more effective when reversed:
- Verify whether
Resources.UnloadUnusedAssetsactually reclaimed assets. - If it did not, investigate the AssetBundle unloading strategy.
- Only after confirming successful reclamation should execution timing be further optimized.
Some projects intentionally keep AssetBundles resident to reduce loading stalls. In these cases, repeated Resources.UnloadUnusedAssets calls are unlikely to produce meaningful memory savings.
A more scalable approach is to implement a tiered AssetBundle cache, allowing bundle lifetime to be managed according to factors such as:
- LRU (Least Recently Used)
- Player location
- Distance from the player
- Memory pressure conditions
Lower-priority bundles can then be unloaded together when memory pressure occurs—for example, after Application.lowMemory is triggered—before executing resource cleanup.
Timing Strategies
As for execution timing itself, two strategies are commonly used:
1. Periodic Cleanup
Run Resources.UnloadUnusedAssets periodically, such as every 5–10 minutes.
2. Memory Pressure Cleanup
Execute cleanup only after receiving the Application.lowMemory callback.
Running Resources.UnloadUnusedAssets while opening full-screen interfaces like an inventory or map is also a valid option, since players generally tolerate a brief pause in these contexts.
However, this approach only provides value if the cleanup actually reclaims memory.
Key Takeaway
Before spending time optimizing when Resources.UnloadUnusedAssets runs, first verify that each execution is genuinely releasing resources.
Otherwise, every cleanup may simply become another expensive "empty run".
Top comments (0)