Search Unity

Huge Garbage Collection Spikes

Discussion in 'Scripting' started by Hypester, Jun 28, 2019.

  1. Hypester

    Hypester

    Joined:
    Jan 23, 2018
    Posts:
    17
    Hey guys,

    My Garbage Collector spikes me down to 10 frames per second all of a sudden. It seems to be focused on GC Alloc for StackTraceUtility.ExtractStackTrace() & .PostprocessStacktrace(), but I'm already way out of my depth in terms of figuring out how to find the problem. I'm wondering if its related to the huge memory leak the Unity editor has been giving me in the realm of 10GB that just keep running even after I exit play mode or even Unity. I don't know if I wrote some bad code or what, but I'm not sure where to start looking. I found a tweet by a guy who had the problem, but they refactored their project to get past it without knowing exactly what they relate to. I've attached what I see in the profiler to see if anyone recognizes those processes.
     

    Attached Files:

  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    Every time you call Debug.Log, or an error or warning is triggered (that's how you get the whole path of "how did we even get to this function?" when you click on a console log), a stacktrace is performed, which in large numbers is a big performance hog and GC generator. Do you have some Debug.Log's happening that you don't need?
     
  3. Hypester

    Hypester

    Joined:
    Jan 23, 2018
    Posts:
    17
    I got rid of the only debug.log I had, and the spikes are still in place. What I have in the console are a lot of lines similar to this. They all seem to relate to the MotionController I'm using, so I guess I'll check with them. Thanks for your thoughts.


    Parameter 'L0MotionStateTime' does not exist.
    UnityEngine.Animator:SetFloat(String, Single)
    com.ootii.Actors.AnimationControllers.MotionController:SetAnimatorProperties(MotionState&, Boolean) (at Assets/ootii/Assets/MotionController/Code/Actors/AnimationControllers/MotionController/MotionController.cs:2374)
    com.ootii.Actors.AnimationControllers.MotionController:OnControllerLateUpdate(ICharacterController, Single, Int32) (at Assets/ootii/Assets/MotionController/Code/Actors/AnimationControllers/MotionController/MotionController.cs:1172)
    com.ootii.Actors.ActorController:InternalUpdate(Single, Int32) (at Assets/ootii/Assets/ActorController/Code/Actors/CharacterControllers/ActorController.cs:1412)
    com.ootii.Actors.ActorController:ControllerLateUpdate(Single, Int32) (at Assets/ootii/Assets/ActorController/Code/Actors/CharacterControllers/ActorController.cs:1371)
    com.ootii.Actors.BaseSystemController:LateUpdate() (at Assets/ootii/Assets/Framework_v1/Code/Actors/BaseSystemController.cs:264)
    com.ootii.Actors.ActorController:LateUpdate() (at Assets/ootii/Assets/ActorController/Code/Actors/CharacterControllers/ActorController.cs:1324)

     
  4. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,251
    Here's something we wrote a while ago that might help narrow it down.

    Game Development and GC

    A real killer is also the use of strings.
     
    Hypester likes this.
  5. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    I guess I could have been more broad in that anything that is getting outputted to the Console, with few exceptions, will cause stacktraces. So those warnings definitely will do that.