Obi Official Forum

Full Version: Per-Frame GC Allocation in Burst Solver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
While profiling, I hit on a pretty obvious per-frame GC allocations in the Burst Solver: the padding array in BurstSolverImpl.ApplyConstraints.

The allocation can be avoided by using a stack-allocated span, the number of enum entries is small enough:
Code:
Span<int> padding = stackalloc int[Oni.ConstraintTypeCount];

However, I'm not sure since when exactly Unity supports C# 7.2, so for older versions, a statically allocated array might be due.
(28-12-2021, 10:39 AM)pdinklag Wrote: [ -> ]While profiling, I hit on a pretty obvious per-frame GC allocations in the Burst Solver: the padding array in BurstSolverImpl.ApplyConstraints.

The allocation can be avoided by using a stack-allocated span, the number of enum entries is small enough:
Code:
Span<int> padding = stackalloc int[Oni.ConstraintTypeCount];

However, I'm not sure since when exactly Unity supports C# 7.2, so for older versions, a statically allocated array might be due.

Thanks for the feedback!
Not sure about C# version support in older (read: < 2020) Unity versions, so will investigate and apply this to the production branch if it all looks clear Sonrisa.