Search Unity

Garbage Collection in DOTS?

Discussion in 'Entity Component System' started by andreicfsteaua, Mar 16, 2020.

  1. andreicfsteaua

    andreicfsteaua

    Joined:
    Nov 18, 2019
    Posts:
    36
    Hello! I am a beginner in unity dots and monobehaviours but I am heavily focused on learning dots. I started building a very small project with just a few basic scripts using pure dots exclusively. Everything works fine around 5ms per frame but occasionaly i get big spikes with 130-140ms a frame. Using the profiler I have noticed that it doesn't have to do with my scripts at all but with the rendering of the scene which freezes it. I have installed entities 0.7 and the hybrid renderer 0.4 (something strange that i noticed is that its dependency is entities 0.8 but somehow it works). I will provide you with the screenshot of the profiler. Can someone give me some insight of what's happening? Thank you a lot.
    https://prnt.sc/rh8j4k
    https://prnt.sc/rh8j0d
    https://prnt.sc/rh8liw
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    The GC spike is being triggered by the NativeContainer safety system. This is simply a debugging tool and does not exist in builds. You can also disable it in the editor, though unless you are A/B-ing a Burst optimization, is not recommended.

    I am surprised you are accumulating GC quick enough to notice these spikes though. Are you sure none of your scripts are generating GC?
     
  3. andreicfsteaua

    andreicfsteaua

    Joined:
    Nov 18, 2019
    Posts:
    36
    I could write here my scripts but it might take a bit to think in terms of GC
     
  4. andreicfsteaua

    andreicfsteaua

    Joined:
    Nov 18, 2019
    Posts:
    36
    Here they are. The rest are just tags with authoring components. I don't really have an idea in terms of GC. Does DOTS need GC btw?
     

    Attached Files:

  5. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    4,267
    You can check the GC Alloc column in the profiler hierarchy view. Outside of the safety sentinels, core DOTS with struct components should be GC-free.