Search Unity

Bug Huge Memory leak when using a second camera

Discussion in 'Graphics for ECS' started by StefanWo, Apr 6, 2023.

  1. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122
    I have a second camera attached to the scene, rendering to a RenderTexture (usecase: Profile Pictures of persons rendered to the UI). In the editor and in Unity 2021 with entities 51 everything worked fine, but in the Build, it causes a huge memory leak (around 12gb in less than a minute). I used the Memory Profiler and find the reason in the GfxDeviceClient. I couldn't found anything related to it.

    I tried a different approach to keep the camera disabled and call the Render method by hand every frame. This worked fine, also my fps increased a lot. Not sure if this is intended to be like this and also not sure if i am in the right forum for that :)

    Using Unity 2022.2.13 with Entities-graphics-pre65 and the URP Pipeline with Forward+ rendering on a windows build.
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
  3. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122
    I also saw that post and actually changed the code in UpdateEntitiesGraphicsBatches already :(

    Its just happening with the 2. camera adding to the rendering. With my mentioned workaround to call it by hand with a disabled camera its working. So i looks like a different problem to me.
     
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    Submit bug report if u confirmed it's different issue
     
  5. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122
    Yeah, i have a workaround now, creating a real bug report cost me too much time. I have another issue, that my compiler not working every time properly, that cost additional. Due to its just happening in the compiled version, it will cost multiple days to do so.
     
  6. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    351
    I was not able to reproduce a leak by simply placing a second camera with a RenderTexture output in a simple scene. Whatever is causing your leak probably requires some kind of more specific circumstances. Repro projects are very important for us to be able to fix issues like this.
     
  7. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122
    Yes i understand, thanks for trying it out! Hope i find the time to reproduce it in a simplified repo.
     
  8. StefanWo

    StefanWo

    Joined:
    May 24, 2015
    Posts:
    122