Example #1
0
        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");
                }
            }
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            int depth = 0;

            if (ObjectId.HasValue)
            {
                bool first = true;
                var  path  = heapshot.GetShortestPathToRoot(ObjectId.Value).ToArray();
                long rootId;
                if (path.Length == 0)
                {
                    DrawRow(e, ObjectId.Value, 0);
                    rootId = ObjectId.Value;
                    depth++;
                }
                else
                {
                    foreach (var item in path)
                    {
                        if (first)
                        {
                            DrawRow(e, item.Source, depth++);
                            first = false;
                        }
                        DrawConnection(e, session.GetFieldName(item.Source, 0), depth);
                        DrawRow(e, item.Target, depth++);
                    }
                    rootId = path.Last().Target;
                }
                if (heapshot.Roots.TryGetValue(rootId, out var root) && !string.IsNullOrEmpty(root))
                {
                    DrawConnection(e, root, depth);
                }
            }
            base.OnPaint(e);
        }