.NET memory leak?

Posted by SA on Stack Overflow See other posts from Stack Overflow or by SA
Published on 2009-08-27T07:35:03Z Indexed on 2010/03/14 12:35 UTC
Read the original article Hit count: 174

Filed under:
|
|

I have an MDI which has a child form. The child form has a DataGridView in it. I load huge amount of data in the datagrid view. When I close the child form the disposing method is called in which I dispose the datagridview

    this.dataGrid.Dispose();
    this.dataGrid = null;

When I close the form the memory doesn't go down. I use the .NET memory profiler to track the memory usage. I see that the memory usage goes high when I initially load the data grid (as expected) and then becomes constant when the loading is complete.

When I close the form it still remains constant. However when I take a snapshot of the memory using the memory profiler, it goes down to what it was before loading the file. Taking memory snapshot causes it to forcefully run garbage collector.

What is going on? Is there a memory leak? Or do I need to run the garbage collector forcefully?

More information:

When I am closing the form I no longer need the information. That is why I am not holding a reference to the data.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about memory