Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to find memory leak

Discussion in 'Prefabs' started by P3ndragonLLC, Aug 31, 2021.

  1. P3ndragonLLC

    P3ndragonLLC

    Joined:
    Sep 19, 2019
    Posts:
    99
    Hello,

    I'm creating gameobjects from asset bundles. It works correctly in terms of showing the game objects after my code runs, but when I destroyobject on them, it doesn't free all the memory. I see my scene object count return to it's previous number, but the memory being used grows and grows.

    Do I need to deallocate something that's getting allocated from the asset bundle load call, or does it all just have to do with my prefabs or scripts I'm adding to them at run time and nothing to do with the asset bundles? How do I find what the kind of thing that's being held in memory after the destroy object is called?

    Thanks!
     
  2. howardmealor

    howardmealor

    Unity Technologies

    Joined:
    May 21, 2021
    Posts:
    18
    Hi P3ndragonLLC. Here's a thread discussing asset bundles and memory management issues:
    https://forum.unity.com/threads/how-does-asset-bundles-manage-the-memory.1055402/

    It's worth reading this in-depth article which relates to your scenario: https://blog.unity.com/technology/l...age-by-improving-the-way-you-use-assetbundles

    If you're not already using Unity's memory profiler, it could help you identify memory management problems:
    https://docs.unity3d.com/2020.2/Documentation/Manual/com.unity.memoryprofiler.html

    If it turns out that you believe you have found a bug, then please create a simple project and steps to reproduce the memory leak and submit it in a bug report to ensure that your issue gets developer attention. Thanks.
     
    Last edited: Sep 1, 2021
    MartinTilo likes this.
  3. P3ndragonLLC

    P3ndragonLLC

    Joined:
    Sep 19, 2019
    Posts:
    99
    Thanks, that's what I needed. I came up with a way to unload bundles based on usage and then re load them so they can be used again if the player goes back to that area.
     
    howardmealor likes this.