Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Garbage Collection issues in NetworkPostLateUpdate

Discussion in 'Netcode for GameObjects' started by joseph114591452, Aug 15, 2023.

  1. joseph114591452

    joseph114591452

    Joined:
    Mar 14, 2020
    Posts:
    29
    I'm facing issues with Garbage Collection and I don't know how to debug it.
    Every once in a while there is a lag spike caused by the Garbage Collector.

    Here is `GC.Alloc` called every frame.
    Screenshot 2023-08-15 at 4.42.19 AM.png

    Here is `GC.Collect` causing the lag spike.
    Screenshot 2023-08-15 at 4.42.36 AM.png

    Is there a way to find the code allocating the memory?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,659
    Do you have deep profiling enabled? If not I‘d try that first.
     
  3. joseph114591452

    joseph114591452

    Joined:
    Mar 14, 2020
    Posts:
    29
    Thank you, deep profiling was helpful.
    I don't understand the cause of this issue but it doesn't seem to be related to my code.
     
  4. Kossano

    Kossano

    Joined:
    May 10, 2023
    Posts:
    12
    You found any sort of solution to this? I've created an empty project. And after couple enters into PlayMode game may go as low as to 10FPS or so.
    Settings for NetworkManager
    upload_2023-8-19_23-38-16.png

    upload_2023-8-19_23-39-23.png

    And the result is this is piling up.
     
    Last edited: Aug 19, 2023
  5. Kossano

    Kossano

    Joined:
    May 10, 2023
    Posts:
    12
    For anyone that's end up looking for it here is how I managed to resolve it:

    NGO 1.5.2 and unity 2022.3.7f1 with incremental GC & reload domain on play mode enter.
     
    joseph114591452 likes this.