Sitelet https://github.com/unoplatform/uno/pull/24969
Skip to content

perf(dependencyobject): lazily initialize property dictionaries - #24969

Open
daaviid9 wants to merge 1 commit into
unoplatform:masterfrom
daaviid9:perf/dependencyobject-lazy-dictionaries
Open

daaviid9 wants to merge 1 commit into
unoplatform:masterfrom
daaviid9:perf/dependencyobject-lazy-dictionaries

Conversation

@daaviid9

@daaviid9 daaviid9 commented Oct 4, 2026

Copy link
Copy Markdown

Avoid allocating _inheritedForwardedProperties and _propertyChangedTokens dictionaries during DependencyObject construction until first write. This saves ~176 B per instance and avoids eager allocation for objects that never receive forwarded properties or property changed callbacks.

GitHub Issue: closes #24752

PR Type:

🔄 Refactoring (no functional changes, no api changes)

What changed? 🚀

Changed _inheritedForwardedProperties and _propertyChangedTokens in DependencyObject.Store.cs to be lazily initialized using ??=. This resolves a memory allocation regression where empty dictionaries were eagerly allocated for every DependencyObject instance. Added unit tests to verify the lazy initialization behavior.

PR Checklist ✅

Avoid allocating _inheritedForwardedProperties and _propertyChangedTokens
dictionaries during DependencyObject construction until first write.
This saves ~176 B per instance and avoids eager allocation for objects
that never receive forwarded properties or property changed callbacks.

Fixes unoplatform#24752
@CLAassistant

CLAassistant commented Oct 4, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Oct 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DependencyObject constructor always allocates two empty Dictionary fields, even when unused

2 participants