|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Declaring a garbage collectorHi,
Is there a way to delcare a garbage collector in VB.NET 2005? Thanks, Adam Adam,
Can you tell more what you mean with "a" garbage collector? Cor Show quoteHide quote "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... > Hi, > > Is there a way to delcare a garbage collector in VB.NET 2005? > > Thanks, > Adam > Like in Java where they have a sub that's called when the program is to
terminate. It releases any used resources and basically cleans up. Adam Show quoteHide quote "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message news:eumDjvacGHA.3840@TK2MSFTNGP04.phx.gbl... > Adam, > > Can you tell more what you mean with "a" garbage collector? > > Cor > > "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht > news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... >> Hi, >> >> Is there a way to delcare a garbage collector in VB.NET 2005? >> >> Thanks, >> Adam >> > > Adam,
That is one of the main differences between Java and Net and why it is called Managed Code. Net does that for you on the best time. You would not wanted to force that. (Which is possible, however will cost a lot of total throughput time) Cor Show quoteHide quote "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht news:eZ8n8xacGHA.1260@TK2MSFTNGP05.phx.gbl... > Like in Java where they have a sub that's called when the program is to > terminate. > > It releases any used resources and basically cleans up. > > Adam > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:eumDjvacGHA.3840@TK2MSFTNGP04.phx.gbl... >> Adam, >> >> Can you tell more what you mean with "a" garbage collector? >> >> Cor >> >> "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht >> news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... >>> Hi, >>> >>> Is there a way to delcare a garbage collector in VB.NET 2005? >>> >>> Thanks, >>> Adam >>> >> >> > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: Java and .NET have similar garbage collectors...> That is one of the main differences between Java and Net and why it is > called Managed Code. Net does that for you on the best time. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> Herfried,
If I had not you, This is was what I had understood from our Java Guru in these newsgroups, I probably have understood him wrong. Cor Show quoteHide quote "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht news:%23jbtIHccGHA.5116@TK2MSFTNGP04.phx.gbl... > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb: >> That is one of the main differences between Java and Net and why it is >> called Managed Code. Net does that for you on the best time. > > Java and .NET have similar garbage collectors... > > -- > M S Herfried K. Wagner > M V P <URL:http://dotnet.mvps.org/> > V B <URL:http://classicvb.org/petition/> Use the Closing or Closed events. (FormClosing or FormClosed in .NET 2.0).
The first one occurs before the form is closed, and gives you the opportunity to stop the form from closing. The second one occurs after the form is closed. Adam Honek wrote: Show quoteHide quote > Like in Java where they have a sub that's called when the program is to > terminate. > > It releases any used resources and basically cleans up. > > Adam > > "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message > news:eumDjvacGHA.3840@TK2MSFTNGP04.phx.gbl... >> Adam, >> >> Can you tell more what you mean with "a" garbage collector? >> >> Cor >> >> "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht >> news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... >>> Hi, >>> >>> Is there a way to delcare a garbage collector in VB.NET 2005? >>> >>> Thanks, >>> Adam >>> >> > > Adam,
It sounds like you want to declare a Finalizer. A Finalizer is used to "releases any used resources and basically cleans up". Generally if you are declaring a Finalizer you also want to implement IDisposable. For more infor on implementing Finalizers & Disposable see: http://msdn.microsoft.com/msdnmag/issues/04/05/NETMatters/ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconImplementingDisposeMethod.asp http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconFinalizeDispose.asp -- Show quoteHide quoteHope this helps Jay B. Harlow [MVP - Outlook] ..NET Application Architect, Enthusiast, & Evangelist T.S. Bradley - http://www.tsbradley.net "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> wrote in message news:eZ8n8xacGHA.1260@TK2MSFTNGP05.phx.gbl... | Like in Java where they have a sub that's called when the program is to | terminate. | | It releases any used resources and basically cleans up. | | Adam | | "Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message | news:eumDjvacGHA.3840@TK2MSFTNGP04.phx.gbl... | > Adam, | > | > Can you tell more what you mean with "a" garbage collector? | > | > Cor | > | > "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht | > news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... | >> Hi, | >> | >> Is there a way to delcare a garbage collector in VB.NET 2005? | >> | >> Thanks, | >> Adam | >> | > | > | | Hello Adam
let me try to shine some light on the subject :-) In java when you want to invoke the GC you need to do this Runtime objFoo = Runtime.getRuntime(); objFoo.gc(); in .Net however the GC is in the system namespace so the equivalant for above java code would be GC.Collect() However as Cor mentioned calling the GC.Collect method to cause an induced garbage collection is usually a bad idea The only valid situation i can think of is when the application is idle and if you see that unexpected garbage collections are slowing down the application during time critical operations ( example : your program is in charge of controling hardware devices that require a short response time ) In all other situations i would say , let the GC doe it`s work as how it was intended to do so , as this gives you the highest performance Regards And happy coding :-) Michel Posseth [MCP] Show quoteHide quote "Adam Honek" <AdamHo***@Webmaster2001.freeserve.co.uk> schreef in bericht news:ePTqOhZcGHA.4108@TK2MSFTNGP03.phx.gbl... > Hi, > > Is there a way to delcare a garbage collector in VB.NET 2005? > > Thanks, > Adam > |
|||||||||||||||||||||||