all groups > dotnet clr > august 2005 >
You're in the

dotnet clr

group:

When Garbage Collector Runs?



Re: When Garbage Collector Runs? Javier Martinez
8/17/2005 12:00:00 AM
dotnet clr: When a object does a memory request (new) if there isn't memrory enough to
statisfaced it the garbage is started

"Ganesh" <Ganesh@discussions.microsoft.com> escribió en el mensaje
news:0337785B-B91B-4B5F-B309-13C4105B712A@microsoft.com...
[quoted text, click to view]

When Garbage Collector Runs? Ganesh
8/17/2005 1:32:01 AM
Hi,

I just want to know when the garbage collector runs? Is there any condition
that should meet before the garbage collector gets executed?.

Re: When Garbage Collector Runs? Jon Shemitz
8/17/2005 11:38:28 AM
[quoted text, click to view]

No, this isn't quite right. Garbage collection IS triggered by a
memory request, but the garbage collector does NOT wait for an
out-of-memory condition.

The garbage collector keeps track of how much memory has been
allocated since the last collection. When "enough" memory has been
allocated, it does a collection. The garbage collector watches program
behavior, and adjust the trigger poinmt automatically. (There are also
"generations", but that is probably too deep for such a basic
question.)

There's a reasonably clear explanation at
<http://www.midnightbeach.com/jon/pubs/2002/BorCon.London/dotNetArchitecture.html>
.....

--

Re: When Garbage Collector Runs? Nick Hertl
8/23/2005 2:51:57 PM
You can also trigger one with System.GC.Collect() but you should rarely
actually need to use this. If you want to have more control over your
memory management, try using Finalizers and IDisposable for your
objects where this is important.

You will find that objects cleaned up by a Dispose() call will have
vastly better performance than objects that are automatically finalized
by the GC.
AddThis Social Bookmark Button