Memory Leak and Increased Process Memory in UWP App Load the ListBox Items when Opening the Popups with Custom ListBox View

Anandhan Rajagopal 1 Reputation point

Issue: The application's process memory exhibits a continuous increase, particularly noticeable when frequently opening and closing popups containing a custom ListBox view. This behavior suggests a potential memory leak within the UWP platform. Especially the issue occurs due to subscribing to the loaded and unloaded event in the prepare item container override method of the list box. we have unsubscribed the events properly but still, the memory leak occurs.


  1. Reproduction Steps:
    • Open the application.
    • Perform actions to trigger the opening and closing of popups containing the custom ListBox view using the click button.
    • Repeat the process multiple times.
  2. Expected Behavior:
    • The application's memory consumption should remain stable even with frequent popup interactions.
  3. Observed Behavior:
    • With each iteration of opening and closing popups, there's a noticeable increase in process memory usage.
    • The memory consumption keeps growing, indicating a potential memory leak.

Sample Link:

Issue Output Video:

Universal Windows Platform (UWP)
{count} votes

1 answer

Sort by: Most helpful
  1. Junjie Zhu - MSFT 13,516 Reputation points Microsoft Vendor

    Hi @Anandhan Rajagopal ,

    Welcome to Microsoft Q&A!

    I can also reproduce the same behavior.

    At first, I also thought it was related to event registration, but it doesn’t seem to be the key point of this problem.enter image description here

    It is recommended to define max1 as a global variable, and the leak will disappear.

     List<object> max1 = new List<object>();
     public MainPage()
             Employees = new List<Employee>();
         max1.Add(new Employee { Name = "Lucas", Email = "" });
         max1.Add(new Employee { Name = "James", Email = "" });
         max1.Add(new Employee { Name = "Jacob", Email = "" });
     private void popup_Opened(object sender, object e)
         CustomBox.ItemsSource = max1;

    Thank you.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments