Home All Groups Group Topic Archive Search About
Author
11 Jan 2006 2:05 PM
Rob
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 !

Author
11 Jan 2006 3:46 PM
Cyril Gupta
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
Author
11 Jan 2006 4:15 PM
Rob
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
>
Author
12 Jan 2006 2:19 PM
Rob
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
>
Author
12 Jan 2006 2:28 PM
Armin Zingler
"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
Author
12 Jan 2006 3:45 PM
Peter Proost
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)

Show quoteHide quote
"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
>