Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Garbage Collector + VSync leads to stuttering ?

Discussion in 'General Graphics' started by Victor_Luxinten, Nov 27, 2018.

  1. Victor_Luxinten

    Victor_Luxinten

    Joined:
    Apr 22, 2017
    Posts:
    2
    Hello everyone,

    I started working with Unity not too long ago and wanted to start with a very basic game : a side scrolling runner.
    Since the very beginning I encounter one classic problem : stuttering.
    EDIT : I also tried with an empty project with VSync every V Blank and I get the exact same behavior.

    Moving objects + camera are all inside one game object which is moved using : transform.Translate(Vector3.forward * speedManager.GetSpeed() * Time.deltaTime);

    Every popping asset is stored to be reused, so the "only" thing the garbage collector has to handle during game time is a string which contains the score that increases.
    The speed isn't a constant but I still have stuttering with a constant value.

    One way to stop the stuttering is to disable vsync, but I target mobiles with that game and I doubt rendering at high fps is battery wise - still the movement doesn't appear really smooth.

    So I kept on investigating and figured that my GC's allocated memory had a regular spike (from 10KB to 41KB) which matches a non-existing vsync (it takes 0ms instead of using about 8~9ms to keep with the 60fps). See attached screenshot.
    UnityProfiler.PNG

    Does anyone know if it's something I might have done wrong ? Are there some parameters to change ? Is this a "Unity" / GC / VSync issue ?

    For information : I'm using 2018.2.11f1 (but experiencing that from older versions though).

    EDIT : tried with 2019.1 alpha to try Incremental GC and it's even worse. What's weird is that disabling GC doesn't stop the GC Allocated memory from having its spikes.
     
    Last edited: Nov 28, 2018