PolylinePath updates and GC
First of all, thank you for this library, it is truly amazing and extremely versatile, and for sure something Unity was lacking.
I do have a question about best practices when it comes to updating a PolylinePath.
My scenario is very simple. I have a PolylinePath with about 100 points which I want to update every frame (position, color, and thickness).
I tried different techniques:
- Every frame I ClearAllPoints and I use AddPoint
- I initialize the PolylinePath in Awake/Start (with AddPoint) and then I use SetPoint every frame
- I create a new PolylinePath every frame, add the points, draw, then dispose.
The problem that I am facing is that there is something allocating 227KB (GC.Alloc) every frame in my OnPreRenderer function, which triggers some GC spikes every ~200 frames where a GC.Collect takes between 80-110ms which results in a very visually noticeable stutter. I don't really understand why this is happening as PolylinePoint is a struct and should be allocated on the stack, so doing something like p.SetPoint(i, newPolylinePoint(..... should stay away from any CG.Alloc.
What should I do to reduce the GC allocs and spikes?
I am using version 3.2.3 (I haven't upgraded yet due to the breaking changes), is there an improvement in this regard in the newer versions? I checked the changelog but I didn't find anything.