LineRenderer.widthCurve causes memory allocation

Hello,

I am working with LineRenderers and are updating them in Update. It’s working well, however, it seems that accessing the LineRenderer.widthCurve causes memory to be allocated.

I have confirmed by disabling the LineRenderer that this is in-fact one of our biggest performance bottlenecks at the moment, so I am quite sure that this is worth pursuing further

Our usage of the LineRenderer looks like this, it’s like a ‘Rope’ that the character swings on

8449010--1120673--upload_2022-9-19_14-12-43.png

It’s made up of 2 LineRenderers, the one with the stripes that are at the center, and the one in the background, which is an ‘Outline’ of the Rope.

And the code looks like this:

Basically the Outline of the rope is matching the widthCurve of the Rope itself, and to do that, we need to access the widthCurve of the Rope

Just wondering if there’s a solution here, or will I need to look at a different Line drawing solution?

Thanks

UPDATE
I managed to eliminate the need to access widthCurve by maintaining a copy of it within the script itself. Any changes we make to the widthCurve gets applied to both the real LineRenderer’s widthCurve as well as our local copy, then we never need to access widthCurve from the LineRenderer.

I also saw lots of GC Alloc coming from access widthCurve.keys, the way to fix this was simple, we can access the key directly using widthCurve<em> instead of widthCurve.keys**