Best way to avoid allocations for updating Polyline points?

Avatar
  • updated

I searched through the forums here, but couldn't find any solution.

Is there any way to avoid allocations? I have 4 polylines (histograms in a zach-like, so relatively few points) that get refreshed every time a level is selected. Updating the points results in GenPolylineMesh allocating 19.2KB. 


In total I'd have close to 200 polylines (50 levels x 4) so caching (at roughly 30K according to the profiler for a new) is workable, but not ideal. Histograms are static for the duration of the game.

Any other ways to reduce allocations/"garbage"? 

Thanks!

Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline
Avatar
Freya Holmér creator

apart from generating all of them once, there's not really a good fix apart from making the Shapes code not allocate. That said, I've done this for the next release, so it should be better down the line! (I don't know when the next update will go live though, we'll see!)

Avatar
radu muresan
Quote from Freya Holmér

apart from generating all of them once, there's not really a good fix apart from making the Shapes code not allocate. That said, I've done this for the next release, so it should be better down the line! (I don't know when the next update will go live though, we'll see!)

Thank you! Do you have a ballpark estimate for going live? Something like "a few weeks" or "a few months" is enough for planning purposes - just need to figure out if I need to address it myself before cert.