Skip to content

Memory Leak with MahApps.TextBox.ContextMenu #3989

@lipchev

Description

@lipchev

Describe the bug

There is a memory leak with the default context menu (MahApps.TextBox.ContextMenu) of all text boxes (as well as the VS one).

Steps to reproduce

  1. Open the demo project
  2. Open the CleanWindowDemo
  3. Open the ContextMenu of the "Quick search" text box
  4. Close the window

Expected behavior

When the parent is unloaded the memory is liberated

Actual behavior

The CleanWindowDemo window is retained in memory via the ContextMenu (see screenshot below)
Setting the MahApps.TextBox.ContextMenu as x:Shared="False" fixes the issue (PR coming)

PS. It's funny how I didn't notice it the last time- but then I must have only profiled the context menu of the "seek bar" and the DropShadowEffect of the text box, but not the context menu of the text box.

Environment

MahApps.Metro version: v2.4.0
Windows build number: Win10 
Visual Studio: 2019 16.8
Target Framework: .Net v4.7.2

Screenshots

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions