void OnObjectIdChanged() { stacktraceView.Items.Clear(); var sf = objectInfo.Allocation.Backtrace.Reverse().Select(b => session.GetMethodName(b)); foreach (var f in sf) { stacktraceView.Items.Add(f); } retentionList.Items.Clear(); if (heapshot.Roots.TryGetValue(objectInfo.ObjAddr, out var root)) { retentionList.Items.Add("Object is root itself:" + root); } else { var shortestPath = heapshot.GetShortestPathToRoot(objectInfo.ObjAddr); foreach (var edge in shortestPath) { var objInfo = heapshot.ObjectsInfoMap[edge.Source]; var typeName = session.GetTypeName(objInfo.TypeId); retentionList.Items.Add(new RetentionItem(typeName, objInfo)); //TODO: Add field to name } if (shortestPath.Any()) { if (heapshot.Roots.TryGetValue(shortestPath.Last().Source, out root)) { retentionList.Items.Add("Root info:" + root); } } else { retentionList.Items.Add("This is weird... Couldn't find path to root"); } } }
void OnObjectIdChanged() { stacktraceView.Items.Clear(); var sf = objectInfo.Allocation.Backtrace.Reverse().Select(b => session.GetMethodName(b)); foreach (var f in sf) { stacktraceView.Items.Add(f); } retentionPaths.Pages.Clear(); var pathsToRoot = heapshot.GetTop5PathsToRoots(objectInfo.ObjAddr); int i = 0; foreach (var path in pathsToRoot.OrderBy(p => p.Count())) { i++; var listBox = new ListBox(); listBox.MouseDoubleClick += (s, e) => { if (listBox.SelectedValue is RetentionItem ri) { var newTab = new ObjectListTab(session, heapshot, new Dictionary <long, List <ObjectInfo> >() { [ri.obj.TypeId] = new List <ObjectInfo>() { ri.obj } }); newTab.InsertTab += InsertTab; InsertTab(newTab, null); } }; var page = new TabPage(listBox) { Text = $"Path {i}" }; retentionPaths.Pages.Add(page); foreach (var edge in path) { var objInfo = heapshot.ObjectsInfoMap[edge.Target]; var typeName = session.GetTypeName(objInfo.TypeId); listBox.Items.Add(new RetentionItem(typeName, objInfo)); //TODO: Add field to name } listBox.Items.Add(new RetentionItem("Root:" + heapshot.Roots[path.Last().Target].Name, heapshot.ObjectsInfoMap[path.Last().Target])); } if (!pathsToRoot.Any()) { if (heapshot.Roots.TryGetValue(objectInfo.ObjAddr, out var root)) { AddSingleEntry("Object is root itself:" + root.Name); } else { AddSingleEntry("This is weird... Couldn't find path to root"); } } referencesList.Items.Clear(); foreach (var r in objectInfo.ReferencesTo) { var obj = heapshot.ObjectsInfoMap[r]; referencesList.Items.Add(new RetentionItem(session.GetTypeName(obj.TypeId) + ": " + r, obj)); } }