473,465 Members | 1,395 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Clearing objects

for years, in every form i create in VB .Net 2005, in the FormClosing event i
insert the following code:

GC.Collect()
GC.WaitForPendingFinalizers()

but now i'm creating an application that has a very complex form and i
notice that the first time that i use that form in the application the form
opens fast, but after that it opens very slowly. I can only think that the
problem has to do with cleaning the variables/objects. Does this code, that
i've been inserting is the right one to clear objects on a form? is the
correct form to do it or does someone has a better option or can you give me
an hint for code optimization in this aspect?

My thanks in Advanced
Oct 30 '08 #1
2 1246
Hello Ricardo

It shouldn`t be necesary to call the GC at all , so remove this code unless
you have a verry good valid reasson to do so
the GC is optimized for best performance by MS , interfering with it`s
collection mechanism wil mostly hurt your applications performance

HTH

Michel Posseth [MCP]
http://www.vbdotnetcoder.com


"Ricardo Furtado" <Ri************@discussions.microsoft.comschreef in
bericht news:A7**********************************@microsof t.com...
for years, in every form i create in VB .Net 2005, in the FormClosing
event i
insert the following code:

GC.Collect()
GC.WaitForPendingFinalizers()

but now i'm creating an application that has a very complex form and i
notice that the first time that i use that form in the application the
form
opens fast, but after that it opens very slowly. I can only think that the
problem has to do with cleaning the variables/objects. Does this code,
that
i've been inserting is the right one to clear objects on a form? is the
correct form to do it or does someone has a better option or can you give
me
an hint for code optimization in this aspect?

My thanks in Advanced
Oct 30 '08 #2
Ricardo,

I am curious who adviced you to do that, as it is stated to be completely
wrong.

Like as Michel wrote there can be reasons, and therefore you can use it.

But certainly not in the way you do, normally you should not even use the
FormClosing event.
(mostly that event is only used to set something and as well only as it is
really needed something as e.cancel = true)

Cor
"Ricardo Furtado" <Ri************@discussions.microsoft.comschreef in
bericht news:A7**********************************@microsof t.com...
for years, in every form i create in VB .Net 2005, in the FormClosing
event i
insert the following code:

GC.Collect()
GC.WaitForPendingFinalizers()

but now i'm creating an application that has a very complex form and i
notice that the first time that i use that form in the application the
form
opens fast, but after that it opens very slowly. I can only think that the
problem has to do with cleaning the variables/objects. Does this code,
that
i've been inserting is the right one to clear objects on a form? is the
correct form to do it or does someone has a better option or can you give
me
an hint for code optimization in this aspect?

My thanks in Advanced

Oct 30 '08 #3

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

Similar topics

2
by: disgracelands | last post by:
In my code i have setup sys.stdout and sys.stderr as file objects so that i can easily track whats going on during the course of my program. So far its proving useful but the objects seem to be...
18
by: Niels | last post by:
Hi group, I have some problems with clearing floated divs. My usual method works fine in Konqueror, but not in Firefox. Here's an example: <html><body> <div id='left' style='float:left;...
2
by: Andrew Poulos | last post by:
If I'm using DOM methods to dynamically create elements in a page is it necessary for me to clear whatever variables I used to create the elements when the page unloads? I'm reading bits and...
10
by: Liz - Newbie | last post by:
Does anyone know how to clear arrays? My C# books talk about creating arrays or talk about using Clear or RemoveAt but these methods don't appear to be available for my array. I have an array...
0
by: Michał Januszczyk | last post by:
is there any way to tell whether the application has entered the shutdown state ? I put some data into aspnet cache. Special callback method is specified that should be called when cache item is...
65
by: Steven Watanabe | last post by:
I know that the standard idioms for clearing a list are: (1) mylist = (2) del mylist I guess I'm not in the "slicing frame of mind", as someone put it, but can someone explain what the...
1
by: RLN | last post by:
Re: Access 2003 I found a method here in the newsgroup that works for clearing checkboxes, but don't understand a particular line of code and how it works. Here is the code: 1. Dim ctrl As...
4
by: Daz | last post by:
Hello everyone. I have a simple problem which can be solved quite simply, I am just going about it the wrong way. I would like to wipe every row from within a named table, but I am not too sure how...
0
by: negmat | last post by:
Hello everyone, I have the following question: I am aware that the objects currently in the cache can be viewed by issuing the following command: SELECT * FROM master.dbo.Syscacheobjects ...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.