How do I avoid memory leaks caused by navigation and page lifecycle?

Platform: .NET MAUI| Category: Performance

Unsubscribe events, avoid capturing UI in long-lived closures, use WeakEventManager/WeakReference or IDisposable patterns for resource-holding ViewModels.

Unsubscribe example:

protected override void OnDisappearing() 

{ 

    base.OnDisappearing(); 

    publisher.SomeEvent -= OnSomeEvent; 

}

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.