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

memory leak when returning result of Observable.ToBinding() from a Markup-Extension #18176

Open
BinaryCraX opened this issue Feb 11, 2025 · 1 comment

Comments

@BinaryCraX
Copy link

Describe the bug

Bindings provided by Markup-Extensions which are constructed from Observables using ToBinding are never unsubscribed from, resulting in a memory leak.

To Reproduce

Sample code:
Extension:

internal class TestMarkupExtension : MarkupExtension
{
    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return Observable.Never<string>().ToBinding(); // will never be unsubscribed
    }
}

Usage:

<TextBlock Text="{local:TestMarkup}" />

I created a Demo-Project to demonstrate the issue. Click the "Toggle"-Button multiple times and watch the debug-output. The subscription to the observable in the ViewModel gets disposed properly, but the subsciption to the observable from the MarkupExtension doesn't.

Expected behavior

The subscription should be disposed when the view get's removed.

Avalonia version

11.2.3, 11.0.10

OS

Windows

Additional context

No response

@maxkatz6
Copy link
Member

Seems like a duplicate of #5872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants