Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix binding related memory leaks #15485

Merged
merged 1 commit into from
Apr 24, 2024
Merged

Conversation

MrJul
Copy link
Member

@MrJul MrJul commented Apr 23, 2024

What does the pull request do?

This PR fixes some memory leaks related to bindings.

What is the current behavior?

When a compiled binding has an AvaloniaProperty or a method in its path, and its source lives longer than the target, then the target is leaked. The same applies for an attached property through a reflection binding.

What is the updated/expected behavior with this PR?

The bindings don't leak.

How was the solution implemented (if it's not obvious)?

Weak events have been used.

Unit tests have been added.

Of the 4 unit tests added, CompiledBinding_To_InpcProperty_With_Alive_Source_Does_Not_Keep_Target_Alive already passed and was added for comparison purposes. The 3 other tests fail without the changes in this PR.

Fixed issues

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0047606-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added this pull request to the merge queue Apr 24, 2024
@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Apr 24, 2024
Merged via the queue into AvaloniaUI:master with commit aa60e5d Apr 24, 2024
10 checks passed
@MrJul MrJul deleted the fix/binding-leaks branch April 24, 2024 13:12
maxkatz6 pushed a commit that referenced this pull request Apr 25, 2024
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Binding a property in datatemplate via a named control caused memory leak
3 participants