private HeapSnapshot GetSnapshotFromDumpHeap_Stat(string heapdump) { // protect against ill-formatted "!dumpheap -stat" output or unrelated text HeapSnapshot snapshot; try { snapshot = HeapSnapshotFactory.CreateFromHeapStat(heapdump); } catch (InvalidOperationException x) { snapshot = null; } return(snapshot); }
private void AddDumpFile(string dumpFile) { // try to open the dump file try { var snapshot = HeapSnapshotFactory.CreateFromDumpFile(dumpFile); AddOneSnapshot(snapshot); } catch (InvalidOperationException x) { MessageBox.Show(this, GetExceptionMessages(x), $"Error while loading {dumpFile}", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); } }
private HeapSnapshot GetSnapshotFromDumpHeap_Stat(string heapdump) { // protect against ill-formatted "!dumpheap -stat" output HeapSnapshot snapshot; try { snapshot = HeapSnapshotFactory.CreateFromHeapStat(heapdump); } catch (InvalidOperationException x) { MessageBox.Show(this, x.Message, "Error while parsing '!dumpheap -stat' output"); snapshot = null; } return(snapshot); }
private void CompareSnapshots() { HeapSnapshot compare = HeapSnapshotFactory.Compare(_reference, _current); HeapSnapshotFactory.DumpSnapshot(compare); // if the check box is checked, don't show the System.* types bool dontShowBCLType = cbDontShowBCLTypes.Checked; // update the Raw UI StringBuilder sb = new StringBuilder(); sb.AppendFormat("HeapSnapshot at {0}\r\n", compare.TimeStamp); sb.AppendFormat(" {0} objects for {1} bytes\r\n", compare.ObjectCount, compare.Size); var entries = from item in compare.TypeStats.AsParallel() where !dontShowBCLType || !IsBclType(item.Value.Name) orderby item.Value.Name select item.Value ; foreach (var entry in entries) { sb.AppendFormat(" {0}\r\n", entry); } tbResult.Text = sb.ToString(); // update the List UI lvCompare.BeginUpdate(); lvFiltered.BeginUpdate(); lvCompare.Items.Clear(); lvFiltered.Items.Clear(); foreach (var entry in compare.TypeStats) { TypeEntryListViewItem item; // Create a wrapping ListViewItem for the filtered list if needed // Note: always present even though DontShowBCLType is checked if (IsFilteredType(entry.Value)) { AddFilteredEntry(entry.Value); } // skip BCL when needed if (dontShowBCLType) { if (IsBclType(entry.Value.Name)) { continue; } } // Create a wrapping ListViewItem for the compare list item = new TypeEntryListViewItem(""); item.Tag = entry.Value; item.SubItems.Add(entry.Value.Count.ToString("#,#")); item.SubItems.Add(entry.Value.TotalSize.ToString("#,#")); item.SubItems.Add(entry.Value.Name); lvCompare.Items.Add(item); // Create a wrapping ListViewItem for the filtered list if needed if (IsFilteredType(entry.Value)) { item.Filtered = true; item.ImageIndex = 0; } } lvCompare.Sort(); lvFiltered.Sort(); lvFiltered.EndUpdate(); lvCompare.EndUpdate(); }