Search Unity

  1. Dismiss Notice
  2. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice

RenderMeshSystemV2 GC spikes in profiler

Discussion in 'Graphics for ECS' started by unitexer, Nov 22, 2019.

  1. unitexer

    unitexer

    Joined:
    Apr 18, 2019
    Posts:
    8
    Hey, everybody.

    I found a strange behavior of rendermeshsystemv2 system in the profiler.

    I created an empty scene with a cube (an entity with Translation and RenderMesh components) on it.

    Code (CSharp):
    1.  
    2. var entityManager = World.Active.EntityManager;
    3. var testCube = entityManager.CreateArchetype(
    4.            typeof(Translation),
    5.            typeof(RenderMesh),
    6.            typeof(LocalToWorld));
    7.  
    8. var cubeEntity = entityManager.CreateEntity(testCube);
    9.  
    10. entityManager.SetSharedComponentData(cubeEntity, new RenderMesh
    11. {
    12.     mesh = _cubeMesh,
    13.     material = _cubeMaterial
    14. });
    15.  
    16. EntityManager.SetComponentData(cubeEntity, new Translation
    17. {
    18.     Value = _cubeTranslation
    19. });
    20.  
    After starting the scene, I see my cube on the screen, but I also see periodic peaks in the profiler caused by the garbage collector. The profiler shows that garbage is created in the unity.rendering.rendermeshsystemv2 -> updatedynamicrenderbatches -> soft shared renderers (please see attached screenshot)

    2019-11-22_11-28-04.png

    Obviously, these peaks will reduce perfomance, and if the problems appear on such a simple test scene that means I'm definitely doing cube creation wrong

    Please advise what I'm doing wrong.
     
    Last edited: Nov 22, 2019
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,790
    Don't profile garbage in the editor, profile it in a build. A lot of safety stuff produces garbage which is stripped at runtime.
     
    unitexer and MNNoxMortem like this.