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.

Question Need help finding the source of a leak

Discussion in 'Scripting' started by InvincibleCat, Jun 28, 2023.

  1. InvincibleCat


    Dec 23, 2014

    I have been trying to hunt down a leak for quite a while now and I am getting a bit desperate as I am really close to launch.
    I should have seek for help sooner and I hope someone will be able to help me :)

    The game is a roguelike. I took 2 snapshots. I force the same seed so basically what I did is:
    Start run -> Take memory snapshot 1
    Got back to menu -> Start run (same seed) -> Take memory snapshot 2

    I have uploaded both memory snapshots here =>
    I hope this will be enough to find the source.

    Thanks in advance :)

  2. KillDashNine


    Apr 19, 2020
    Use the Profiler to find leaks. There is no straightforward answer but it is not very complicated to use and it will show you eg what's eating memory or CPU.
  3. MaskedMouse


    Jul 8, 2014
    The snapshots are from the new memory profiler.
    I find the old memory profiler easier to read out than the new one.

    There is an active bug

    If you're creating UnityEngine.Object type of objects, destroy them once you're done.
    If you're using addressables don't forget to release the instances or asset once you're done with it.

    Are you sure you have an actual leak or are you just guessing?
    Bunny83 likes this.
  4. MartinTilo


    Unity Technologies

    Aug 16, 2017
    This is a different issue. BTW, the mentioned bug is fixed in 2022.3.10f1 which is out today.

    I'd recommend updating to 1.1.x of the memory profiler and looking into all these Leaked Managed Shells
    That References view improvement with the L! and F! buttons is not yet in 1.1 and needs more polish (e.g. icons instead of cryptic letters) but helped to show whats going on here:
    L! = Leaked Shell
    F! = Static Field root
    Refresh Icon = Circular reference, ignore

    Essentially, you are leaking Managed Shells because they are subscribed to static events on TtEvents and never unsubscribed
    Last edited: Sep 22, 2023