private static void PopulateRootObject(ClrRootRefModel rootRef, ClrHeap heap) { var rootObject = new ClrObjectModel { TypeName = rootRef.RootObjectTypeName, Address = rootRef.RootObjectAddress, ReferencedObjects = new List <ClrObjectModel>() }; (uint count, ulong toltalSize) = PopulateReferencedObjects(heap, rootObject); rootObject.TotalSize = toltalSize; rootRef.ObjectCount = count; rootObject.ChildCount = rootRef.ObjectCount - 1; rootRef.RootObject = rootObject; }
private static IList <ClrRootRefModel> BuildRootRefs(ClrRuntime runtime) { var rootRefs = new List <ClrRootRefModel>(); foreach (var root in runtime.Heap.EnumerateRoots()) { var rootRef = new ClrRootRefModel { Address = root.Address, RootObjectAddress = root.Object, Name = root.Name, RootObjectTypeName = root.Type?.Name, }; rootRefs.Add(rootRef); } foreach (var rootRef in rootRefs) { PopulateRootObject(rootRef, runtime.Heap); } return(rootRefs); }