I would like to monitor the # of instances of a given .NET class present in memory over time, excluding instances which have been disposed.
It seems to me that the # I'm looking for is obtained by subtracting the "disposed instances" count to the "live instances" count.
As I always used to have a very ergonomic and practical experience of MemProfiler, I wonder, if this un-practical subtraction is correct.
At first sight, I thought that the "Live instances" count would do the job as it occurs after GC collection. But in this case it should be equal to the sum of "disposed + undisposed" instances, which is not the case !
(my undisposed count remains to zero)
On the other hand, an undisposed instance is an instance whose Dispose method has not been called before it was GCed or finalized. The "Undisposed instances" count is an accumulative value of all instances that have been GCed or finalized without being disposed.
It's possible to investigate a specific disposed instance in a snapshot, since it's an existing instance. Specific undisposed instances cannot be investigated, since they normally no longer exist at the time of the snapshot. To get more information about undisposed instances, the allocation call stacks can be investigated.
SciTech Software AB
Users browsing this forum: No registered users and 22 guests