Reputation: 1817
My understanding is that !dumpheap command list all the object present in the .NET heap that are not garbage collected. In that case if I run !gcroot command against an object address( found through !dumpheap -mt XXX) it should always give me stack trace of where that object is referenced. However I am finding examples where I canot find root of objects listed in !dumpheap. Is my understanding about !dumpheap and !gcroot not correct? If you want to see examples, its described in my other question posted here
Upvotes: 3
Views: 2424
Reputation: 116431
!dumpheap
lists all objects on the managed heap. Some of these might be eligible for GC (i.e. they are not rooted). The latest version of SOS has -live
and -dead
flags to specifically list objects that can or cannot be reclaimed at this point.
Similarly, !dumpheap
also lists "Free" objects, which are areas of the managed heap that have not been compacted yet. Sample output:
73113f80 1 84 System.Exception
008c4cb8 8 96 Free <--- can be compacted at some point
731142a8 1 112 System.AppDomain
731169a4 1 132 System.Globalization.NumberFormatInfo
731162dc 2 144 System.Globalization.CultureInfo
731141a0 2 168 System.Threading.ThreadAbortException
73116d54 2 280 System.Byte[]
73117684 3 468 System.Collections.Generic.Dictionary`2+Entry[[System.Type, mscorlib], [System.Security.Policy.EvidenceTypeDescriptor, mscorlib]][]
731155f4 11 564 System.Int32[]
73116518 2 616 System.Globalization.CultureData
731147f8 4 718 System.Char[]
73115020 26 728 System.RuntimeType
73113e38 164 5502 System.String
730d0cdc 26 18152 System.Object[]
Upvotes: 7