|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Clean up issuesI 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 ! 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... Show quoteHide quote "Cyril Gupta" <nom***@mail.com> wrote in message news:OhxVpYsFGHA.644@TK2MSFTNGP09.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 ! Show quoteHide quote "Cyril Gupta" <nom***@mail.com> wrote in message news:OhxVpYsFGHA.644@TK2MSFTNGP09.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" <rwch***@comcast.net> schrieb What do you want to clean up? Variables are part of the process and don't > 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 ? 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 -- Show quoteHide quoteProgramming 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.nospam@freenet.de> schreef in bericht news:ue3Fac4FGHA.2036@TK2MSFTNGP14.phx.gbl... > "Rob" <rwch***@comcast.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 >
Inheritance
What happened to the Class view in VS2005? Drag and Drop to SysTray ? VB 2005 - How to hook into Windows to intercept all mouse events? Hide Window form (top most) Novice Question About Webclient Handling Events in VB.Net A place to discuss future vb featuresause? Menu is disapearing in 2005 uint32 conversion on win32_pingstatus |
|||||||||||||||||||||||