Hi y’all,
I was wondering if someone could help me out with an odd garbage collection behavior I’m seeing. I’m very new to Unity so forgive me if this ends up being dumb. We have a point in our project where the user can view what in our code ends up being a very large collection of objects (another player and all their assets). They can cycle through other players and each time they go to the next the previous one is unloaded. Going to the next causes a severe drop in the framerate and a huge CPU spike in the profiler that lasts for a few seconds and then goes away. Now, this sort of makes sense but what seems odd is that it’s not GC.Collect that’s causing the hit it’s GC.MarkDependencies and it shows up in the profiler with the color for “other”. I added an explicit call to GC.Collect after unloading the player that should complete before you could press the next button again but it didn’t change the behavior at all. Any help on figuring out what’s hijacking our CPU would be most appreciated.