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, ...
Get Shared Source CLI Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.