Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Kinematica: Crash due to high memory usage when using snapshot debugger

Discussion in 'Animation Previews' started by randomPoison, Apr 22, 2021.

  1. randomPoison


    Apr 3, 2021
    I've run into a case where the snapshot debugger will rapidly allocate memory until the system runs out of memory and Unity crashes:


    In a project that uses Kinematica for animation, the following steps can reliably reproduce the issue:
    1. Enter play mode.
    2. In the snapshot debugger window, begin recording.
    3. Record at least a few seconds of animation data (i.e. where at least one character is animating through Kinematica).
    4. Pause the snapshot debugger (either by pressing "pause recording" or by clicking on the snapshot debugger timeline).
    5. In the snapshot debugger window, ensure that a valid target is selected (i.e. one that is animated using Kinematica).
    6. Pause the entire game simulation using the main editor pause button.
    7. Open the Kinematica Execution Graph window.
    8. Click on the "Find Closest Pose & Trajectory" node in the Kinematica Execution Graph window.
    9. Using your system's performance monitor (e.g. the Task Manager on Windows) observe the amount of memory used by the Unity editor.
    At that point you should see memory usage climb noticeably over the period of a minute or so. If you don't interact with the editor, memory usage will continue to climb until Unity crashes.

    These repro steps might be able to be simplified further. I've noticed that I don't always need to click on a node in the execution graph window, sometimes simply having that window open is enough to cause memory usage to climb while the game is paused. I'll update the thread if I can confirm a simpler set of repro steps.

    So far I've also found the following workarounds that can trigger Unity to reset the extra memory usage:
    • Un-pausing the editor.
    • Stepping the game forward by one frame.
    • Moving the mouse cursor over the scene view or game view, or clicking on either of those.
    If I end up digging into this more and find a cause or fix, I'll update the thread with the additional info.