O'Reilly logo

Shared Source CLI Essentials by Ted Neward, Geoff Shilling, David Stutz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reclaiming Memory

Reclamation in the SSCLI consists of two principal steps: the copying of promoted ephemeral objects into the elder generation, followed optionally by a sweep of the elder generation for dead objects. A copy collection performed without a sweep is called an ephemeral collection to contrast it to a full collection. For either kind of collection, an initial liveness trace is used to distinguish live from dead objects within the generations that have been condemned (designated for collection); generation zero is traced alone for ephemeral collection, while both generations are traced for full collection.

Note

The SSCLI garbage collector, like many of the runtime services, is heavily instrumented in logging . Not only does this help find and fix bugs, but it can also be very useful for understanding how it works. Try setting the COMPlus_LogLevel environment variable to 9 and the COMPlus_LogFacility environment variable to 0x80001 (which is a combination of the flag for logging the roots found and the flag for logging collection itself) and both COMPlus_LogToConsole and COMPlus_LogEnable to 1, to watch the garbage collector in action when running your programs. If you really want to go crazy, set COMPLus_GCtraceStart to 1, and you will see a live play-by-play trace of every action. See sscli/docs/techinfo/logging.html for detailed documentation on logging.

To quickly and safely visit all objects during the trace, all threads running managed code are suspended (except, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required