Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Why does HDRP generate so much GC allocs?

Discussion in 'Graphics Experimental Previews' started by Nothke, Feb 8, 2019.

  1. Nothke

    Nothke

    Joined:
    Dec 2, 2012
    Posts:
    108
    I noticed in my game (on 2018.3) that I get occasional freezes due to GC kicking in. Looked at the profiler and behold, 1.3KB of allocs every frame caused by PostLateUpdate.FinishFrameRendering things. I built the sample template project to make sure it's not caused by me, and yeah, still 1.3KB of allocs.

    From build and attached profiler:



    It's not the first time I notice this, but last time I noticed it was in 2018.1, so I thought it will be fixed in the next update. Am I doing something wrong and there is some setting that will prevent it? If not is this just how the core of SRP works or is it just HDRP? Is this something that we can expect will be fixed soon?

    It's kind of strange that new Unity features like jobs and ECS are giving us the power to avoid GC allocs but on the other hand we get this that generates loads of garbage. Yes, I understand it's "experimental" but this kind of stuff seems to be so basic that it can be avoided from start.
     
  2. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    195
    Pick unity 2019.1 and setup incremental GC at the player settungs it must reduce overall gc spike and spread overhead through couple frame
     
  3. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    6,893
    That's not really a solution to why HDRP generates so much garbage in the first place.

    @Nothke I believe they are planning to bring the garbage allocations down.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,997
    hippocoder likes this.
  5. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,727
    The incremental GC will not run at editor time, for many reasons. This is a Unity staff decision, just a heads up.

    HDRP team is aware of the allocations, but HDRP isn't likely going to be a first class citizen until 2019.3 - but feel free as Peter suggested, to post a bug report.
     
  6. Nothke

    Nothke

    Joined:
    Dec 2, 2012
    Posts:
    108
    I thought if I don't mention incremental gc someone will mention it right away. And I was right. I wanted to keep focus on the allocs themselves instead. Incremental gc is not an answer to why allocs exist at all I agree with @AcidArrow

    My question was "why?", I wanted to find out what really requires allocating new objects/arrays every frame in hdrp. Isn't it possible to allocate this stuff on start and why isn't this something that wasn't a priority from start? When I make games, that's always in the back of my mind.

    But it's good that the team is aware of it. So 2019.3? Huh, that's almost a year away sadly :(
     
    Velo222 likes this.
  7. FlightOfOne

    FlightOfOne

    Joined:
    Aug 1, 2014
    Posts:
    248
    Same problem in 2019.4.1f1 LTS.

    I submitted a bug report.
     
    Last edited: Jun 20, 2020
unityunity