Options

I am seeing an issue where an event that is not getting unregistered not shown in profiler

As part of a technical discussion of memory profiling, I purposely added events that were not unregistered in my company's Winforms-WPF application. There was no indication of a memory leak in the profiler. I then wrote a smaller WPF application that just pops up a window. The DataContext of the window has an event that is not getting unregistered...yet I never see instances of the popup window in the memory profiler. I am using VS2019. See attached project.
Tagged:

Answers

  • Options
    jegray12jegray12 Posts: 3 New member
    Forgot to mention I am running Version 11.0.0.1816 standard
  • Options
    jegray12jegray12 Posts: 3 New member
    In MainWindow.xaml.cs, I register for an event that I never unregister from.
    I would expect there to be a buildup of PopupWindow instances as I open and close the window, but I see no instances in the profiler.

     private void Button_Click(object sender, RoutedEventArgs e)
            {
                TestDataContext data = new TestDataContext();
                data.CloseEvent += Window_CloseTestEvent;

                PopupWindow window = new PopupWindow(data);
                window.ShowDialog();
            }

            private void Window_CloseTestEvent(object sender, System.EventArgs e)
            {
                //if (sender is TestDataContext window)
                //    window.CloseEvent -= Window_CloseTestEvent;
            }
  • Options
    Hello jegray12

    Without a solution to examine I'm admittedly speculating, based on your description I anticipate the flawed logic you instituted failed to grow sufficiently to meet the required threshold for it to be identified.
    https://documentation.red-gate.com/amp/understanding-memory-problems/memory-management-primer

    The tooling aims to highlight what is growing excessively, as opposed to what conceptually could.
    Kind regards
    Peter Laws | Redgate Software
    Have you visited our Help Center?
Sign In or Register to comment.