Repository navigation
fix: Don't let the DP storage pools keep arrays of collected objects (6.7) - #26252
Merged
agneszitte merged 3 commits intoNov 9, 2026
Merged
Conversation
_entryOffsets is indexed by bucketIndex alone, so it needs bucketIndex + 1 slots, but it rented (bucketIndex * BucketSize) + 1 - a 16x over-allocation. Because bucketIndex derives from DependencyProperty.UniqueId, a process-wide counter, the waste scales with the highest property id an object touches: with ~2000 properties registered in Uno.UI alone, a DependencyObject that sets a late-registered property carried a 4 KB short[] where 256 bytes suffice. The multiplier bought nothing. ArrayPool rounds a request up to a power-of-two bucket, so growth stays geometric and resizes stay amortized O(1); the total allocated across resizes is now ~2x the final size rather than one 16x slab. The oversized InitBlockUnaligned fill shrinks with it. Measured at bucket index 17: 512 slots rented for 18 needed, now 32. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_016yv4DH5RYAoVM8GjEWtXDS (cherry picked from commit fbfead4)
DependencyPropertyDetailsCollection.Dispose returned its entries and offsets arrays to static pools that keep up to 8192 arrays per bucket. Dispose mostly runs from the DependencyObjectStore finalizer, so after each GC the arrays of every collected DependencyObject went back to the pools at once, while the live UI kept its own. The pools ended up holding the largest number of objects any single GC collected, for the life of the process. Leave the final arrays to the GC instead, as 7.0 does (its storage no longer uses pools). Arrays released while a collection grows are still pooled. Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit 04197b6)
Co-Authored-By: Claude Opus 5.5 <[email protected]> (cherry picked from commit ef6084e)
Contributor
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
agneszitte
approved these changes
Nov 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
6.7 copy of #26220 (merged into
servicing/6.8). These are the same 3 commits, cherry-picked unchanged.Servicing-only change: there is no master PR to backport. 7.0 already fixes this differently. #23703 removed the
DependencyObjectfinalizer, and #25047 replaced the pooled property storage with arrays allocated directly. Both depend on the 7.0DependencyObjectrefactor, so they aren't suitable for servicing.GitHub Issue: closes unoplatform/kahua-private#571
PR Type:
🐞 Bugfix
What changed? 🚀
On 6.x, each
DependencyObjectkeeps its property values in aDependencyPropertyDetailsCollection, with two arrays rented from static pools: theDependencyPropertyDetails?[]entries (LinearArrayPool) and theshort[]offsets (ArrayPool<short>.Shared). Those pools keep up to 8192 arrays per bucket and trim slowly.Arrays of collected objects filled the pools (8f4bdf5)
Disposereturned both arrays to the pools. On Skia it runs from theDependencyObjectStorefinalizer, so after each GC the arrays of every collected object went back to the pools at once, while the live UI kept its own.Disposenow leaves the final arrays to the GC, as 7.0 does. Arrays released while a collection grows are still returned to the pools, so the resize path keeps its reuse.Borderand +13% perColumnDefinition. perf: Size DependencyProperty storage to the properties set #25047 reports a similar cost on master.The offsets array was rented 16x too large (36d2a2d)
This is a cherry-pick of
fbfead433ffrom master, unchanged._entryOffsetsis indexed by bucket index alone, but it rented(bucketIndex * 16) + 1slots instead ofbucketIndex + 1.Tests (
Given_DependencyPropertyDetailsCollection, unit tests)When_DependencyObjects_Collected_Then_Storage_Arrays_Collected: without the fix, all 200 arrays of 100 collectedColumnDefinitions outlive them, because the pools hold them.When_Store_Disposed_Then_Storage_Arrays_Not_Returned_To_Pools: covers an explicitDisposeof the store, which iOS/macOS native views use.When_Property_In_High_Bucket_Then_Offsets_Sized_To_Bucket_Index: without the cherry-pick, it fails with 256 offsets rented for bucket index 12.The tests keep weak references to the object's own arrays, so they don't depend on what else is in the pools. These weak references track resurrection: plain ones are cleared before the store's finalizer hands the arrays to the pools.
masterhas aGiven_DependencyPropertyDetailsCollection.cswith different tests (for the 7.0 table). Should 6.x ever be merged into master, keep master's version.Validation
Uno.UI.UnitTests, net10.0, Windows, on this branch):Given_DependencyObject*,Given_DependencyProperty*,BuffersandBinder: 275 passed, 0 failed, 3 skipped.DependencyPropertyDetailsCollection.cs,DependencyObjectStore.csandsrc/Uno.UWP/Buffers/are identical between that base and this one.PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code