Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    Dismiss Notice
  2. 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

Garbage Collection Constant Lag Spikes?

Discussion in 'Editor & General Support' started by vsnry, Dec 9, 2018.

  1. vsnry


    May 4, 2018
    Hi, I have a procedural voxel terrain which works fine, but suffers from constant framerate drops. I looked at the profiler and it seems to be a garbage collection problem, as you can see in the video it happens constantly at the exact same interval, even when standing still when no chunks are getting created or destroyed. How do I fix this?

  2. Peter77


    QA Jesus

    Jun 12, 2013
    MartinTilo likes this.
  3. Mark-Davis


    Jun 21, 2011
    The above link is a definitely a good place to start. A few quick thoughts... even though you're not creating the chunks every frame, it wouldn't be much of a stretch to imagine that you might be processing the chunks in some way every frame whether that involves traversing an octree or priority sorting for a grid structure. If you have anything that requires instantiating a new List or Array each frame, maybe see if you can preinstantiate it, and then clear and reuse it each frame instead... and hopefully structs are an option. One more thing... some annoying performance hiccups magically disappear when you compile. I've wasted days at a time on in-editor reoccurring performance hiccups only to discover that they don't actually exist in the wild. Good luck!