docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Find memory leaks

    Memory leaks cause your application to perform worse over time and might lead to a crash.

    Memory leaks typically happen for one of the following reasons:

    • Missing code to release objects from memory.
    • Unintentional references keeping objects in memory.

    To identify memory leaks, capture and compare multiple snapshots. Refer to Compare two snapshots for more information.

    Detect memory leaks after scene unload

    Leaks often result from user-allocated objects or resources not released after a scene unload.

    To identify this type of leak perform the following steps:

    1. Open Window > Analysis > Memory Profiler.
    2. Use the Attach to Player dropdown to set the source as a running Player.
    3. Load an empty scene and create a snapshot of it.
    4. Load the test scene, play partway through, then unload it or change to an empty scene. To fully unload assets, call Resources.UnloadUnusedAssets or load two new scenes consecutively.
    5. Take another snapshot and optionally close the Player.
    6. Compare snapshots and use any of the Memory Profiler tabs to inspect the snapshots.

    Increased memory usage in the second snapshot might indicate a memory leak.

    Additional resources

    • Compare two snapshots
    • Memory Profiler window reference
    • Analyzing Unity object memory leaks
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)