Search Unity

Memory Profiling - tracked a memory leak to a blank Native Object Name

Discussion in 'Editor & General Support' started by mattbrandmm, Sep 22, 2020.

  1. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    I have been using the Memory Profiler package for the last couple days, trying to pin down a memory leak in my suite of games. The one very glaringly obvious culprit is an 8.0MB texture that appears after returning to a main menu after playing one of the games (see screenshot below).

    The trouble is that the Native Object Name is blank, and I have no idea how to track where this texture is coming from. I call Resources.UnloadUnusedAssets when returning to the main menu, so I'm not sure why it would not get cleaned up.

    Is there any way to get more information about a texture showing up in the memory snapshot using one of the other fields?

    upload_2020-9-22_6-35-33.png
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hi there,
    Is this perchance a snapshot made while profiling the game in Playmode, or is this from a build player?
    If it is from the Editor, there is a chance that this is a Memory Leak in the Memory Profiler UI itself, that we have fixed already and will ship with com.unity.memoryprofiler@0.2.6-preview.1. More info on that can be found in this thread which was asking the same question.

    In short:
    If you create textures on the fly (i.e. not loading from file but maybe from the web or creating them newly in c#) you can assign a name to it via it's .name property.
    In this case, there is one reference to it i.e. the blue 1 in RefCount column that you can click on to see what references it. That might help you figure out where this came from too.
     
    mattbrandmm likes this.
  3. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    Thanks for the info! This is a snapshot made while profiling the game in Play mode in editor, so it could be a leak in the memory profiler UI itself.

    I did click on the ref count, and got this:
    upload_2020-9-22_7-25-1.png
    which I believe does confirm your answer.
     
    Last edited: Sep 22, 2020
    MartinTilo likes this.
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    It does look like that yes :)
     
    mattbrandmm likes this.
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    mattbrandmm likes this.
  6. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    MartinTilo likes this.