Esempio n. 1
0
 void HandleNewHeapshot(KrofilerSession session, Heapshot hs)
 {
     //hs.BuildReferencesFrom();
     //Console.WriteLine("Hs:" + hs.Name);
     //Console.WriteLine("Objects Count:" + hs.ObjectsInfoMap.Count);
     //int count = 0;
     //foreach (var obj in hs.ObjectsInfoMap.Values) {
     //	if (obj.ReferencesFrom.Count == 0 && !hs.Roots.ContainsKey(obj.ObjAddr)) {
     //		count++;
     //		Console.WriteLine($"{obj.ObjAddr} type:{session.GetTypeName(obj.TypeId)}");
     //		foreach (var b in obj.Allocation.Backtrace) {
     //			Console.WriteLine("   " + session.GetMethodName(b));
     //		}
     //	}
     //}
     //Console.WriteLine("Orphans count:" + count);
     Application.Instance.AsyncInvoke(delegate {
         listViewLeft.Items.Add(new ListItem()
         {
             Text = hs.Name,
             Tag  = hs
         });
         listViewRight.Items.Add(new ListItem()
         {
             Text = hs.Name,
             Tag  = hs
         });
     });
 }
Esempio n. 2
0
 public RetentionGraph(KrofilerSession session, Heapshot heapshot)
 {
     this.heapshot = heapshot;
     this.session  = session;
     Width         = 1000;
     Height        = 2000;
 }
Esempio n. 3
0
        public ObjectListTab(KrofilerSession session, Heapshot heapshot, Dictionary <long, List <ObjectInfo> > typesToObjectsListMap)
        {
            this.typesToObjectsListMap = typesToObjectsListMap;
            this.session     = session;
            this.heapshot    = heapshot;
            this.Orientation = Orientation.Horizontal;
            CreateTypesView();
            filterTypesTextBox              = new TextBox();
            filterTypesTextBox.TextChanged += FilterTypesTextBox_TextChanged;
            this.SplitterWidth              = 10;
            var filterAndTypesStackLayout = new StackLayout();

            filterAndTypesStackLayout.Items.Add(new StackLayoutItem(filterTypesTextBox, HorizontalAlignment.Stretch));
            filterAndTypesStackLayout.Items.Add(new StackLayoutItem(typesGrid, HorizontalAlignment.Stretch, true));

            this.Panel1 = filterAndTypesStackLayout;
            CreateObjectsView();
            var splitter2 = new Splitter()
            {
                Orientation = Orientation.Horizontal
            };

            splitter2.SplitterWidth = 5;
            splitter2.Panel1        = objectsGrid;
            objectPanel             = new ObjectDetailsPanel(session, this.heapshot);
            objectPanel.InsertTab  += (a, b) => InsertTab?.Invoke(a, b ?? this);
            splitter2.Panel2        = objectPanel;
            Panel2        = splitter2;
            this.Position = (int)Screen.PrimaryScreen.Bounds.Width / 3;
        }
Esempio n. 4
0
        public CompareHeapshotsTab(KrofilerSession session, Heapshot hs1, Heapshot hs2)
        {
            this.session = session;
            if (hs2.Id > hs1.Id)
            {
                newHeapshot = hs2;
                oldHeapshot = hs1;
            }
            else
            {
                newHeapshot = hs1;
                oldHeapshot = hs2;
            }
            var diff              = new DiffHeap(oldHeapshot, newHeapshot);
            var newObjects        = diff.NewObjects.GroupBy(addr => addr.TypeId).ToDictionary(d => d.Key, d => d.ToList());
            var deleted           = diff.DeletedObjects.GroupBy(addr => addr.TypeId).ToDictionary(d => d.Key, d => d.ToList());
            var allObjectsInOldHs = oldHeapshot.TypesToObjectsListMap;
            var allObjectsInNewHs = newHeapshot.TypesToObjectsListMap;
            var hashTableAllTypes = new HashSet <long>();

            foreach (var t in allObjectsInOldHs)
            {
                hashTableAllTypes.Add(t.Key);
            }
            foreach (var t in allObjectsInNewHs)
            {
                hashTableAllTypes.Add(t.Key);
            }
            foreach (var typeId in hashTableAllTypes)
            {
                typesCollection.Add(new TypeChangeInfo {
                    TypeId       = typeId,
                    TypeName     = session.GetTypeName(typeId),
                    NewObjects   = newObjects.ContainsKey(typeId) ? newObjects[typeId] : EmptyList,
                    DeadObjects  = deleted.ContainsKey(typeId) ? deleted[typeId] : EmptyList,
                    OldHsObjects = allObjectsInOldHs.ContainsKey(typeId) ? allObjectsInOldHs[typeId] : EmptyList,
                    NewHsObjects = allObjectsInNewHs.ContainsKey(typeId) ? allObjectsInNewHs[typeId] : EmptyList
                });
            }
            filterTypesTextBox              = new TextBox();
            filterTypesTextBox.TextChanged += FilterTypesTextBox_TextChanged;
            CreateTypesView();
            var filterAndTypesStackLayout = new StackLayout();

            filterAndTypesStackLayout.Items.Add(new StackLayoutItem(filterTypesTextBox, HorizontalAlignment.Stretch));
            filterAndTypesStackLayout.Items.Add(new StackLayoutItem(typesGrid, HorizontalAlignment.Stretch, true));

            Content = filterAndTypesStackLayout;
        }
Esempio n. 5
0
        public DiffHeap(Heapshot oldHs, Heapshot newHs)
        {
            OldHeapshot = oldHs;
            NewHeapshot = newHs;

            var oldAllocs = oldHs.ObjectsInfoMap.ToDictionary(p => p.Value.Allocation, p => p.Value);
            var newAllocs = newHs.ObjectsInfoMap.ToDictionary(p => p.Value.Allocation, p => p.Value);

            foreach (var a in oldAllocs)
            {
                if (!newAllocs.Remove(a.Key))
                {
                    DeletedObjects.Add(a.Value);
                }
            }
            // What is left in list is new
            NewObjects.AddRange(newAllocs.Values);
        }
            public override void Visit(HeapEndEvent ev)
            {
                processingHeapTime.Stop();
                var deadAllocations = new HashSet <long>();

                foreach (var key in allocationsTracker.Keys)
                {
                    if (!currentHeapshot.ObjectsInfoMap.ContainsKey(key))
                    {
                        deadAllocations.Add(key);
                    }
                }
                foreach (var key in deadAllocations)
                {
                    allocationsTracker.Remove(key);
                }

                session.NewHeapshot?.Invoke(session, currentHeapshot);
                currentHeapshot = null;
            }
Esempio n. 7
0
 void HandleNewHeapshot(KrofilerSession session, Heapshot hs)
 {
     Application.Instance.Invoke(delegate {
         var hsButton = new Button {
             Text = hs.Name
         };
         listViewLeft.Items.Add(new ListItem()
         {
             Text = hs.Name,
             Tag  = hs
         });
         listViewRight.Items.Add(new ListItem()
         {
             Text = hs.Name,
             Tag  = hs
         });
         hsButton.Click += delegate {
             InsertTab(new ObjectListTab(session, hs, hs.TypesToObjectsListMap), this);
         };
         commandButtonsStack.Items.Add(hsButton);
     });
 }
Esempio n. 8
0
 public override void Visit(HeapBeginEvent ev)
 {
     currentHeapshot = new Heapshot(session, ++heapshotCounter);
 }
 public override void Visit(HeapBeginEvent ev)
 {
     processingHeapTime = Stopwatch.StartNew();
     currentHeapshot    = new Heapshot(session, ++heapshotCounter);
 }