Search Unity

Bug Terrain trees are leaking runtime created materials into memory (keeping referenced textures alive)

Discussion in 'World Building' started by Raul_T, Jan 26, 2023.

  1. Raul_T

    Raul_T

    Joined:
    Jan 10, 2015
    Posts:
    363
    As per title.

    Terrains with trees assigned will leak the terrain generated material instances for them into memory. This happens when the terrain has trees assigned but drawing is currently disabled waiting to be enabled when necessary.

    upload_2023-1-26_16-47-27.png

    upload_2023-1-26_16-47-21.png

    Extra notes:
    - This happens on windows 11, unity 2022.3.44f1
    - Happens on both my nvidia 3070ti, and intel a770 gpus
    - There are other leaking materials from the terrain as well though the ones from vegetation are more troublesome.

    When looking in the memory profiler all the material objects for the given tree appear in the memory with 0 references to them, while they keep reference of the textures assigned thus keeping them alive from unloading.

    upload_2023-1-26_16-49-21.png

    I have submitted a bug report
    Case IN-30065

    Repro steps in attached project:
    1) Oepn project
    2) Add GameDummy scene to build settings and build a development build
    3) Run, attach Memory Profiler to build and do a sample
    4) Search memory objects by Material type - you will notice all the foliage materials with 0 references as in the screenshot above. They reference textures.
     

    Attached Files:

    DEEnvironment likes this.
  2. mattb-unity

    mattb-unity

    Unity Technologies

    Joined:
    Feb 7, 2020
    Posts:
    55
    Thanks for the bug report and all these excellent details!
     
    MartinTilo likes this.