Search Unity

Streaming world stutters due to manual GC

Discussion in 'Editor & General Support' started by NestorAlgieri, Feb 21, 2019.

  1. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    I have a streaming world that will stream smoothly, so the async loading and unloading is not a problem. However when unloading sectors that are getting far away from the player, even tho all objects in the sector scenes that are unloaded are destroyed, it remains in memory unless you call Resources.UnloadUnusedAssets() manually, or else it will eventually crash due to OutOfMemory.
    So the only way to solve this is to call Resources.UnloadUnusedAssets().

    Here's the issue, when calling UnloadUnusedAssets() that causes the game to pause for a half second, enough to cause the game to feel very interrupted.

    - What is everyone who makes open streaming worlds with Unity doing about this issue?
    - What do you folks who work at Unity suggest?
     
  2. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Unity 2018.3 ships with an improved GC, that is spread across multiple frames to avoid frame-rate drops. Have you tried 2018.3 already?

    Every bigger or open-world'ish Unity game I've played (on my Xbox) suffered from this issue. The only Unity game that ran butter smooth for me is INSIDE and it's "just a side-scroller".

    PlayDead's solution to stutter free frame-rates in Unity was to buy a source license and fix the engine code, as presented in this Unite talk:

    Please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. You can post the Case number (number only, not the link) in this forum thread for Unity staff to pick up, in case they see it.
     
  4. NestorAlgieri

    NestorAlgieri

    Joined:
    Sep 11, 2011
    Posts:
    299
    Hi I use 2018.3 Not sure how to activate that multiple frame GC.
    So you mean UnloadUnusedAssets() which calls GC, is not supposed to cause stutter?
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I was wrong, it's available in 2019.1:
    https://blogs.unity3d.com/2018/11/26/feature-preview-incremental-garbage-collection/
    In 2019.1, you can enable it in "Edit > Project Settings > Player" and the option is called "Use incremental GC".

    I would consider it a bug. It's pretty much not applicable to use in a game (outside a loading screen), if it causes the game to stand still for a second.