Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Opening a context flyout on a text box leaks memory

Open BAndysc opened this issue 1 year ago • 5 comments

Describe the bug

Opening a context flyout on a text box leaks memory

To Reproduce

  1. git clone https://github.com/BAndysc/avalonia-bugs-repro
  2. git checkout bug_windows_input_panel
  3. Run the app, press the button to open a new window
  4. Open a context menu in the text box
  5. Close the second window
  6. Memory leak:

image

Expected behavior

No response

Avalonia version

11.0.10, 11.2.999-cibuild0047556-alpha

OS

Windows

Additional context

Target is set here: https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Controls/Flyouts/PopupFlyoutBase.cs#L238 and will only be released when the next menu is opened

BAndysc avatar Apr 22 '24 14:04 BAndysc

@maxkatz6 Target no longer keeps a strong reference, but unfortunately the issue is still valid.

image

BAndysc avatar Apr 23 '24 12:04 BAndysc

The left path is caused by PlacementTarget this time:

image

BAndysc avatar Apr 23 '24 12:04 BAndysc

Actually, it looks like solving this issue is as simple as resetting the value https://github.com/AvaloniaUI/Avalonia/pull/15478

BAndysc avatar Apr 23 '24 12:04 BAndysc

The PR fixes the left path, but there are still other retention paths

image

BAndysc avatar Apr 23 '24 13:04 BAndysc

^ The leak is still valid in the latest nightly, can we reopen this issue or should I open a new issue?

BAndysc avatar Apr 25 '24 09:04 BAndysc