Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Cinemachine generates garbage.

Discussion in 'Cinemachine' started by georgeq, Apr 13, 2018.

  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    660
    While optimizing my game I discovered that Cinamchine causes GUI.Repaint to generate garbage on every frame, with one Cinamachine brain but no virtual camera active, it generates 384 bytes of garbage, with one virtual camera active it generates 1.1KB of garbage. With 12 active cameras it generates 9.8 KB of garbage. With all virtual cameras and the Cinemachine brain disabled, GUI.Repaint generates no garbage.
     
    knik85 likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,241
    This should be happening in editor only. All the OnGUI calls in CM are wrapped in #if UNITY_EDITOR. No garbage will be generated in the build.
     
    wanrclhnyd and knik85 like this.
  3. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    660
    Thanks, is good to know!
     
  4. StupydHors

    StupydHors

    Joined:
    Oct 25, 2016
    Posts:
    25
    Sorry for the necro but. It seems this is still the case and it is pretty annoying when profiling the game.
    Would it be possible to add an "AND" type compiler constant to the #if UNITY_EDITOR so that we can disable it?
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,241
    CM generates no garbage if you turn off the "Show Debug Text" options and keep the inspectors hidden.
     
    GuirieSanchez likes this.
  6. h4voc

    h4voc

    Joined:
    Mar 2, 2015
    Posts:
    12
    Sorry to bring this up again. I have 336B GC alloc when having an CM Brain component active on my camera.( Show debug is turned off) See my screenshots.
    cm_brain_alloc.PNG

    cm_brain_config.PNG

    If i disable the CM brain, the 336B alloc is gone.

    What can i do?
     
    Last edited: Dec 10, 2022
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,241
    What version of CM?
    We don't get any GC allocs with the latest release (2.9.4)