473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unloading forms

I am confused about when a form is unloaded, if ever. I have forms loading
as MDI forms that have a withevents reference to a global class raising
events. When the forms close, the closed event fires, etc., but the raised
event continues to be captured in the forms. The form is opened from a sub
on the main form, like

Dim frm as frmMine

frm = new frmMine
frm.show

The frm is a local variable to the sub so goes out of scope with the sub.

Why would this continue to fire, and how can I get the form to unload. In
general, I have tested a few sample apps that have simply an MDI that opens
a form and when the form has some databound controls linked to a dataset,
when the form's close the memory use stays the same or even increases:
reopen the form and the memory increases, repeat over and over and the
memory grows. Calling gc.collect has no effect, but if I reduce the form to
hidden and re-open then the memory drops down to very little and when I
re-open the form it remains small. What gives?

Thanks for any help, I am fairly new to .Net.

Glenn
Nov 21 '05 #1
3 1166
Hi Glenn,

One way is to call Form.Close to reclaim memory and destroy the form.

http://msdn.microsoft.com/library/de...CloseTopic.asp

HTH
rawCoder

"Glenn" <g.***@comcast.net> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
I am confused about when a form is unloaded, if ever. I have forms loading
as MDI forms that have a withevents reference to a global class raising
events. When the forms close, the closed event fires, etc., but the raised event continues to be captured in the forms. The form is opened from a sub on the main form, like

Dim frm as frmMine

frm = new frmMine
frm.show

The frm is a local variable to the sub so goes out of scope with the sub.

Why would this continue to fire, and how can I get the form to unload. In
general, I have tested a few sample apps that have simply an MDI that opens a form and when the form has some databound controls linked to a dataset,
when the form's close the memory use stays the same or even increases:
reopen the form and the memory increases, repeat over and over and the
memory grows. Calling gc.collect has no effect, but if I reduce the form to hidden and re-open then the memory drops down to very little and when I
re-open the form it remains small. What gives?

Thanks for any help, I am fairly new to .Net.

Glenn

Nov 21 '05 #2
I no longer have a reference to the form elsewhere to call close: once the
procedure that opened the form ends, its reference that was used to open it
is gone.

The user is closing the form through the X box and the form's closed event
is firing: doesn't this mean the form is closed? However its form level
withevents variable is still receiving events fired elsewhere.

Thanks.

Glenn
"rawCoder" <ra******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hi Glenn,

One way is to call Form.Close to reclaim memory and destroy the form.

http://msdn.microsoft.com/library/de...CloseTopic.asp
HTH
rawCoder

"Glenn" <g.***@comcast.net> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
I am confused about when a form is unloaded, if ever. I have forms loading as MDI forms that have a withevents reference to a global class raising
events. When the forms close, the closed event fires, etc., but the raised
event continues to be captured in the forms. The form is opened from a

sub
on the main form, like

Dim frm as frmMine

frm = new frmMine
frm.show

The frm is a local variable to the sub so goes out of scope with the sub.
Why would this continue to fire, and how can I get the form to unload. In general, I have tested a few sample apps that have simply an MDI that

opens
a form and when the form has some databound controls linked to a dataset, when the form's close the memory use stays the same or even increases:
reopen the form and the memory increases, repeat over and over and the
memory grows. Calling gc.collect has no effect, but if I reduce the

form to
hidden and re-open then the memory drops down to very little and when I
re-open the form it remains small. What gives?

Thanks for any help, I am fairly new to .Net.

Glenn


Nov 21 '05 #3

"Glenn" <g.***@comcast.net> wrote in
I am confused about when a form is unloaded, if ever.
You'll need to get familiar with the Garbage Collection model.
Why would this continue to fire, and how can I get the form to unload.


The form isn't unloaded, it is probably waiting for the next garbage
collection sweep. If you want it to release those WithEvents variables,
then you'll have to tell it to do that as it is closing down....

LFS
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Wayne Wengert | last post by:
In VB6 I used to use frmForm1.Show to make a form visible to the user and then use Unload frmForm1 to unload it. I have an app in which I need to "load" and "unload" forms based on user actions....
1
by: LilleSkutt | last post by:
I want to use assemblies (Window Forms as .dll) so that I can replace the form while the main application is running. To accomplish this, I used Assembly.LoadForm to manually load the assembly when I...
9
by: Rom Marshall | last post by:
Hi. Once a LOB size goes beyond 32KB in size, I'm not able to use the LOAD utility to unload the data off the tables for DB2 7.1 on OS/390. Instead, the documentation refers to a sample C++...
5
by: vineeth | last post by:
Hi I have GUI assembly which is loaded into a seprate Appdomain using AppDomain::Load method, after using it's function i unloaded the assembly by calling the AppDomain.UnLoad() method. But i can...
2
by: Guru Prasad | last post by:
Is there a delay involved in unloading assemblies once a virtual directory is "deleted" using IIS Manager ? At times even after the virtual directory is removed i cannot delete the backing physical...
10
by: peter hansen | last post by:
I tried a couple of weeks ago but I'll try again :D I old VB6-days it was possible to unload a form bu using the Unload(Form) command. I have tried the Close-function but it'll unload the entire...
3
by: Eric A. Johnson | last post by:
In a new project I'm creating, I have my first form that loads being used as a splash screen, with a timer that activates after 5 seconds. I then want the main form to load. However, it isn't...
0
by: ibenc | last post by:
Is there a way to prevent w3wp.exe from unloading a particular appDomain. Some parameters, config files? Here is some info about why I need this. I have a long running background thread in...
1
by: Geoff | last post by:
VB6. When selecting from drop down menu options I display different forms by using the Load (filename) and leave the form with Unload(Filename) The Load event allows me to program the ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.