I have a simple application consisting of about 4 forms and a few db
connections...
I would like to make sure that I have done proper clean up when the user
exits the application.
For all connections I have included a...
cnn,Close()
cnn.Dispose()
Is there something similar that should be done wth Forms ? or variables
within a Sub routine ? or Command objects ? or Datasets ? or DataAdapters ?
Is there some standard code that can be used as a "clean-up catch-all" ?
Thanks ! 5 1302
Hello,
Most data objects have a Dispose method, and some have a close method. You
should call either of which is available, and then you should set the object
to nothing.
myObject = Nothing
But my advice is don't be paranoid about cleaning up. The GCC handles most
cleaning that you would need to do. Are there any problems that you are
facing with the garbage cleaning?
Cyril
Thanks for responding...
No, I have not faced any specific issues... just trying to tidy up things...
I hear somewhat contradictory things about the garbage cleaning... don't
understand what is necessary and what is not...
"Cyril Gupta" <no****@mail.co m> wrote in message
news:Oh******** *****@TK2MSFTNG P09.phx.gbl... Hello,
Most data objects have a Dispose method, and some have a close method. You should call either of which is available, and then you should set the object to nothing.
myObject = Nothing
But my advice is don't be paranoid about cleaning up. The GCC handles most cleaning that you would need to do. Are there any problems that you are facing with the garbage cleaning?
Cyril
Couple more questions on this matter...
Since many of my varables have a scope of the "program's life" where is the
best place to put the clean-up code ? On Closed of the Main Form ? On
Closing of the Main Form ?
Also, is there an easy way to see what has been left open, or not disposed ?
Thanks !
"Cyril Gupta" <no****@mail.co m> wrote in message
news:Oh******** *****@TK2MSFTNG P09.phx.gbl... Hello,
Most data objects have a Dispose method, and some have a close method. You should call either of which is available, and then you should set the object to nothing.
myObject = Nothing
But my advice is don't be paranoid about cleaning up. The GCC handles most cleaning that you would need to do. Are there any problems that you are facing with the garbage cleaning?
Cyril
"Rob" <rw*****@comcas t.net> schrieb Couple more questions on this matter...
Since many of my varables have a scope of the "program's life" where is the best place to put the clean-up code ? On Closed of the Main Form ? On Closing of the Main Form ?
What do you want to clean up? Variables are part of the process and don't
exist anymore after the app has been closed. There's nothing to clean up.
Also, is there an easy way to see what has been left open, or not disposed ?
No. If you write code to create new objects, also write the code to dispose
it, and everything is fine. For example, if I create and use a disposable
object locally, I dispose it locally, too. Something like
dim g as graphics
g = creategraphics
try
'code
finally
g.dispose
end try
Armin
Hi,
to answer your second question: http://memprofiler.com/ is a very handy tool if you suspect you have a
memory leak on a form,project, it can show you which objects have or have
not been disposed and a lot more usefull information.
Hth
Greetz Peter
--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning. (Rich Cook)
"Armin Zingler" <az*******@free net.de> schreef in bericht
news:ue******** ******@TK2MSFTN GP14.phx.gbl... "Rob" <rw*****@comcas t.net> schrieb Couple more questions on this matter...
Since many of my varables have a scope of the "program's life" where is the best place to put the clean-up code ? On Closed of the Main Form ? On Closing of the Main Form ? What do you want to clean up? Variables are part of the process and don't exist anymore after the app has been closed. There's nothing to clean up.
Also, is there an easy way to see what has been left open, or not
disposed ?
No. If you write code to create new objects, also write the code to
dispose it, and everything is fine. For example, if I create and use a disposable object locally, I dispose it locally, too. Something like
dim g as graphics
g = creategraphics
try 'code finally g.dispose end try Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ivanhoe |
last post by:
I need something like html tidy, but for javascript...to fix code
indentation, converts tab/spaces, removes white space, etc...maybe even fast
check sintax and warn on compatibility issues, but I guess it's too much to
ask (?!)
if you have positive expirience with some application(or perl/php script)
that knows how to properly do this (and is customizible and maybe also free
or at least cheap?), please speak up, since all progs I tried...
|
by: roel.schreurs |
last post by:
Sometimes, I want to archive or transport a solution. In such cases, I
would like to remove all redundant files from the solution, i.e. all
compiler output. The documention describes the command line switch
/clean (see
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxlrfclean.asp).
However, when I perform this for a solution, not a single file is
removed. I have seen that the process devenv is actually...
|
by: Rob R. Ainscough |
last post by:
I have a moderately sized web application (30 pages, and 20 DLLs) that takes
10-20 minutes to "Build Solution" after I do a "Clean Solution" -- this is
ONLY apparent after a "Clean Solution"
I have a reasonably power workstation (3.06Ghz dual Zeon with 4GB RAM and
10K RPM hard drives) -- this problem ONLY occurs immediately after I do a
Clean Solution and then "Build Solution" -- if I just run Build Solutions
(one after another) it only...
|
by: Janette |
last post by:
Hi,
Can anyone tell me, if you were to open a connection to a database at the
top of each ASP page in a website, for example like this
<%
dim dbconn
set dbconn=server.createobject("ADODB.connection")
dbconn.ConnectionString= "File name=c:\databaseconnection.udl"
|
by: Nick Gilbert |
last post by:
Hi,
In my VS.NET 2005, if I choose Build Clean Solution, the BIN folder is
not touched. Shouldn't it delete all the dll and pdb files in that
folder first? Instead, I'm finding I have to do it manually.
Also, when I change from Debug to Release, all the pdb files remain in
the bin folder. Shouldn't these be deleted automatically?
Please let me know what the "Clean Solution" is supposed to do (if it's
| |
by: Michael |
last post by:
I have a solution for this, but it feels wrong. If anyone could offer
a better one, I'm all ears. (Or technically, eyes.)
Basically, I have a bunch of classes. For concreteness, one is a
Matrix class, but that's only one example, so please don't get too hung
up on it.
I need to output and input these classes. I'd like a nice, pretty,
human readable output, something like:
1 2 3
|
by: robert maas, see http://tinyurl.com/uh3t |
last post by:
I'm working on examples of programming in several languages, all
(except PHP) running under CGI so that I can show both the source
files and the actually running of the examples online. The first
set of examples, after decoding the HTML FORM contents, merely
verifies the text within a field to make sure it is a valid
representation of an integer, without any junk thrown in, i.e. it
must satisfy the regular expression: ^ *?+ *$
If the...
|
by: Ulysse |
last post by:
Hello,
I need to clean the string like this :
string =
"""
bonne mentalité mec!:) \n <br>bon pour
info moi je suis un serial posteur arceleur dictateur ^^*
\n <br>mais pour avoir des resultats probant il
faut pas faire les mariolles, comme le "fondateur" de bvs
|
by: =?Utf-8?B?YzY3NjIyOA==?= |
last post by:
Hi all,
I usually clean the session when the result page is presented to the user.
At this time, say an email confirmation was sent to the user and a pdf file
they can becdownloaded from the result page.
But if the user click the refresh or back button etc. for some reasons, they
pdf file is not available since it created on the fly when the request was
submitted.
So I am thinking about pull pdf file from database, but don't want the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |