Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Unity 2020 LTS & Unity 2021.1 have been released.
    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 is AddComponent so slow?

Discussion in 'Editor & General Support' started by TFlippy, Jul 28, 2017.

  1. TFlippy


    Nov 12, 2014
    When I was creating entities from code, I noticed that AddComponent<T>() that it produces quite large spikes in the Profiler. Turns out that single AddComponent<TrailRenderer> takes 0.80ms to execute and leaves behind 3.5 KB of data to be GC'd.

    What is it doing? It shouldn't even require Reflection to function as far I know.