This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version]
When a win forms app shows a form with a ListView Control that has its BackgorundImage set it does not release 3 GDI objects each time it is disposed and Garbage collected, this is causing major memeory leaks in our application.
Attached is a sample application to demonstrate the issue.
All I did to re-create this, is the following.
-
Create a new winforms application


-
Add a new form so you have a Form1 and a Form2.

-
Add two buttons on Form1, one to garbage collect, and one to open Form2.
private void btnGarbageCollect_Click(object sender, EventArgs e)
{
GC. Collect();
}
private void btnOpenFormWithListView_Click(object sender, EventArgs e)
{
Form2 oForm = new Form2();
oForm.Show();
}
-
On Form2 add a listview and set a backgroup image from a resource.

-
Open Task manager with the GDIObjects coulmn enabled, and keep opening and closing from 2 from the app and garbage collecting, you will see a jump of 3 GDI objects each time you open and close the form.

Original Comments
Feedback Bot on 9/8/2021, 09:25 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
Marie Shi [MSFT] solved on 9/8/2021, 05:09 PM, 0 votes:
We moved this issue to a relevant GitHub project. Please comment and track it at this URL: dotnet/core#6667
This issue has been moved from a ticket on Developer Community.
[severity:I'm unable to use this version]
When a win forms app shows a form with a ListView Control that has its BackgorundImage set it does not release 3 GDI objects each time it is disposed and Garbage collected, this is causing major memeory leaks in our application.
Attached is a sample application to demonstrate the issue.
All I did to re-create this, is the following.
Create a new winforms application
Add a new form so you have a Form1 and a Form2.
Add two buttons on Form1, one to garbage collect, and one to open Form2.
On Form2 add a listview and set a backgroup image from a resource.
Open Task manager with the GDIObjects coulmn enabled, and keep opening and closing from 2 from the app and garbage collecting, you will see a jump of 3 GDI objects each time you open and close the form.
Original Comments
Feedback Bot on 9/8/2021, 09:25 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Original Solutions
Marie Shi [MSFT] solved on 9/8/2021, 05:09 PM, 0 votes:
We moved this issue to a relevant GitHub project. Please comment and track it at this URL: dotnet/core#6667