Memory recovery for Forms

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
One of problems we faced in EVB was that we cound not unload forms. This was a bottle neck for my application. I am porting this application to VB.NET. I want to recover memory from certains forms once they are not required anymore e.g login form. I am using following syntax.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim f1 As Form1
f1 = New Form1
f1.ShowDialog()
End Sub

When i close form, memory usage level remains at he same level. Even when i repeatedly create and close same form, memory usage begins to increase. Can some body suggest me how can i ensure that memory is recovered as soon as form is closed ?
 
Hello,

When a form is shown using the ShowDialog() method, it is not destroyed
after closing. It is done in this way, so the dialogs can be reused in
order to improve performance. The form is destroyed after closing if it has
been shown using the Show() method.

If you need to use the ShowDialog() method then you can try to call the
Dispose() method in order to free the resources:

form.ShowDialog();
form.Dispose();

Hope this helps.
Thank you,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Thread-Topic: Memory recovery for Forms
| thread-index: AcRoD5YB2bQg1/OjSYmQfmlAUbc2cg==
| X-WBNR-Posting-Host: 195.219.146.25
| From: "=?Utf-8?B?U2FlZWQgQWhtYWQ=?=" <Saeed
(e-mail address removed)>
| Subject: Memory recovery for Forms
| Date: Mon, 12 Jul 2004 05:56:02 -0700
| Lines: 11
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 127.0.0.1
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:57127
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| Hi,
| One of problems we faced in EVB was that we cound not unload forms.
This was a bottle neck for my application. I am porting this application to
VB.NET. I want to recover memory from certains forms once they are not
required anymore e.g login form. I am using following syntax.
| Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
| Dim f1 As Form1
| f1 = New Form1
| f1.ShowDialog()
| End Sub
|
| When i close form, memory usage level remains at he same level. Even when
i repeatedly create and close same form, memory usage begins to increase.
Can some body suggest me how can i ensure that memory is recovered as soon
as form is closed ?
|
|
|
 
Back
Top