Appendix

Information about Delayed Instance Cleanup

The profiler must keep additional information about each allocated instance in the profiled process. This information consists of, e.g., the allocation call stack of the instance.  This extra information must be removed when the instance it is related to is garbage collected. One way for the profiler to be informed about instances that have been garbage collected is to let the Common Language Runtime report all instances that have survived a garbage collection. Any instance that is not reported has obviously been reclaimed by the garbage collector, and the profiler can safely remove the extra information. The problem with this approach is that the garbage collector is highly optimized for large numbers of allocations of short-lived instances. While the garbage collector can perform a very quick generation #0 collect, it has to report all instances to the profiler, which may take a substantially longer time than the collect, especially if the number of surviving instances is high. Thus, by reporting all instances for every garbage collect, the profiled process may run much slower than without profiling.

The solution to this problem is to enable delayed instance cleanup. With delayed instance cleanup, the runtime will not report surviving instances at every garbage collection. Instead, the profiler waits until an instance is overwritten by a newly allocated instance before it removes the additional information of the instance. This adds a slight overhead to the instance allocations routine, but for a process with a large amount of live instances, this will be much less than the overhead of reporting all instances at every garbage collection.

 

 

.NET Memory Profiler User Manual

© Copyright 2002-2009. SciTech Software AB.

For information about .NET Memory Profiler, see the product site at http://memprofiler.com

.NET Memory Profiler is developed by SciTech Software AB