Memory management question -> Form.Close()


Hello,

In one of my winforms pages, I launch another form as follows

  Private Sub btnExtract_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnExtract.Click

        Dim page As New ShowCourses
        page.Show()

    End Sub

  When this form comes up, I fill a datagrid and then set the dataset
and datadapter to nothing.

 After the user looks at the datagrid, they can close this page as
follows:

   Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBack.Click
        Me.Close()
    End Sub

 I observed the Memory Usage for this app from the Processes tab in
the Windows Task Manager and it looked lke the memory usage stayed the
same even though this form was closed.

 How do we close a form and release the memory  it uses back to the
system

 Thank you,

 Burak


Answer this question

Memory management question -> Form.Close()

  • hvymtl

    In principle you do not have to worryabout this, Garbage Collection will eventually be collecting this. you might try a call to <strong>GC.Collect()</strong>,another posting <a href="http://windowsforms.net/Forums/ShowPost.aspx tabIndex=1&tabId=41&PostID=13626#13653">http://windowsforms.net/Forums/ShowPost.aspx tabIndex=1&tabId=41&PostID=13626#13653</a> also discusses this issue.
  • Memory management question -> Form.Close()