|
-
Oct 12th, 2009, 09:24 AM
#1
Thread Starter
Fanatic Member
Unbinding from a DataGridView, memory leak?
Using VS Express 2008 and .NET2.0.
I have a DataGridView which has as its .DataSource a BindingSource, which in turn has its .DataSource set to a BindingList<> which contains some classes.
All works well, and I potentially have a list of several thousand items, and hence several thousand rows on the grid.
When I wish to disconnect binding, clear the list and hence clear the grid, I am setting the grid DataSource property to Nothing, and calling .Clear in the BindingSource.
However, it appears that when I do this, the memory usage (Private bytes) does not reduce until TWO full GC's occur. (Both metrics checked with PerfMon.)
I can only surmise that the original row instances in the grid are hanging around and making it on to the Finalizer queue perhaps?
Is there anything I can do about this, or is it expected behaviour? I'm not sure if setting the DataSource property to Nothing is enough to 'purge' the grid properly.
Using Reflector, I notice that DataGridViewRow inherits Dispose from it's base class, so do I have to call this somehow, or should the act of unbinding do this automatically?
(The classes in the list are purely managed, and have nothing that requires Dispose calling on them.)
Thanks for any help.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|