Search Unity

Question Profiler memory sample still showing unreferenced RenderTextures that have been Released long ago

Discussion in 'General Graphics' started by funkyCoty, Aug 19, 2020.

  1. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    726
    I've got a situation in which I need to allocate and release RenderTextures semi-frequently. I've noticed that despite my RT.Release() calls, they still show up in the memory snapshots that I'm taking with the profiler in Unity. They do show up as "0 bytes," but I've noticed that the garbage collector pauses seem to increase, the more of these RTs build up. Is there a reason why unity or the GC does not actually dispose of these empty RTs? I'm not holding onto their references, so maybe Unity is? Is there a way I can actually delete the references completely?

    Thanks

    upload_2020-8-18_18-41-46.png
     
  2. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    726
    Ahhh.. right after I posted this I realized the solution. Just like with Texture2Ds, you need to Object.Destroy() RTs for Unity to actually release its reference to it for the GC to catch it.
     
    forestrf likes this.