- 수정됨
[Unity] Garbage Collection causing stuttering
Hi, I posted this in Spine -> Editor but might as well try here.
I have twenty one prefabs looping the same animation, but in the profiler, GC.Collect() inside SkeletonRenderer.LateUpdate() causes a number of spikes and noticeable stuttering.
I set the animations only at the beginning, and I don't instantiate anything, and each mesh consists of one material.
I've attached some pictures to help identify what I'm working with here.
Any tips or thoughts on how to improve my performance? If I could spread the collecting over several frames or eliminate it altogether (why aren't animations getting pooled?) it would be grand.
Thanks.
EDIT: Here's me not even using animations. I set up an empty scene with 13 skeletons.
Issue fixed by editing the code in SkeletonRenderer.LateUpdate(). Basically I removed every instance where a variable was declared and used global variables instead.
- 수정됨
Weird. Method-scope variables should live in the stack. I wonder if this might be a thing with Unity or its version of Mono.
And I assumed those were put there for caching purposes since dereferencing object members can be pretty expensive if it's done enough times.
Just curious: Were they references? Arrays? Primitive/value types? A mix?
Or do you have your version of SkeletonRenderer that performed better that we can diff / compare to see what was removed and why it's faster?
Also, what makes you say that Animations aren't "pooled". What do you mean by "pooled" in this context?
Can you send me an isolated Unity Project that exhibits this issue? I'm not able to reproduce a GC Collect in LateUpdate.
<removed>