You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Grid.MeasureCellsGroup leaks its pooled span-store array on the empty-group path #24220
SpanStoreStackVector derives from StackVector<T>, which rents from ArrayPool<T>.Sharedin its constructor (src/Uno.WinRT/Collections/StackVector.cs) and returns the array in Dispose(). Grid.MeasureCellsGroup constructs it before its early return, so that path skips the Dispose() at the end of the method and the rented array is never given back:
SpanStoreStackVectorspanStore=newSpanStoreStackVector();if(cellsHead>=cellCount){return;// <-- never reaches spanStore.Dispose() at the end of the method}
Grid.MeasureOverride calls MeasureCellsGroup up to seven times per measure, once per cell group, and a group head is int.MaxValue when the group is empty — so a typical grid takes the leaking path two to three times per measure while returning only one array. The pool bucket drains, after which every Rent allocates a fresh array.
Expected behavior 🎯
The rented array is returned on every path.
How to reproduce it (as minimally and precisely as possible) 🔬
Measure managed allocations across repeated dirty layout passes of a grid-heavy tree (341 Grids with Auto rows and * columns, 1,365 elements).
Measured impact 📊
Workload
Metric
Before
After
Δ
grid.full-pass
alloc / pass
390,105 B
79,113 B
−79.7 %
grid.full-pass
alloc / element
285.8 B
58.0 B
−79.7 %
grid.full-pass
time / pass
3.67 ms
3.11 ms
−15.3 %
Isolated by reverting and re-applying this change alone on the current tree, both runs executing the workload alone. Allocation figures are byte-identical across runs. The saving is exactly the leaked rentals: ~3 per grid per pass × 341 grids × a 16-element SpanStoreEntry[].
Workaround 🛠️
None available from application code.
Renderer 🎨
Skia
Affected platforms 📱💻🖥️
All platforms 🌍
Uno.Sdk version (and other relevant versions) 📦
Present in current development branches.
Anything else we need to know? 💬
Found by allocation profiling — dotnet-trace attributed by type and call stack — and measured before/after with the same harness. Full evidence: specs/059-performance-improvements/evidence.md.
Activity