Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet?

We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the DataGridView was closed. If the user repeatedly views this report they eventually get an out of memory exception. ANTS Memory Profiler confirmed that the DGV is holding a reference despite dgv.DataSource being set to null.

like image 806
Jerry Fernholz Avatar asked Nov 09 '09 16:11

Jerry Fernholz


1 Answers

Do you have any events registered on the DataGridView like OnClick? Make sure you unregister all events, otherwise it will not be garbage collected

like image 192
SwDevMan81 Avatar answered Sep 26 '22 14:09

SwDevMan81