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. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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


    Jan 10, 2015
    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.



    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.


    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


    Unity Technologies

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