public HeapStats(HeapStatistics stats) { m_Stats = stats; m_IMGUIStats = new IMGUIContainer(OnGUIStats); Add(m_IMGUIStats); }
public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats) { try { HeapCell cell = aCells[0]; System.Diagnostics.Debug.Assert(cell.Type == HeapCell.TType.EFree); // StringBuilder msg = new StringBuilder(); // msg.AppendFormat("This free cell has a {0} byte header and a is occupying a total of {1} byte(s) of heap space.", cell.HeaderSize, cell.Length); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // msg.AppendFormat("In total, this heap contains {0} bytes of free space.", aStats.StatsFree.TypeSize); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // if (cell.Symbol != null) { // Free cells can contain symbols if we attempt to decode them... msg.AppendFormat("The free cell may have originally been of type \"{0}.\"", cell.SymbolString); msg.Append(System.Environment.NewLine + System.Environment.NewLine); } // iLbl_Description.Text = msg.ToString(); } finally { base.PrepareContent(aCells, aStats); } }
public ActionResult HeapStats() { var data = new HeapStatistics { TotalUniqueObjects = 4, Types = new List <HeapTypeStatistics>() { new HeapTypeStatistics() { Count = 1, TotalSize = 10, TypeName = "System.IO.Pipelines.Pipe" }, new HeapTypeStatistics() { Count = 4, TotalSize = 100, TypeName = "Microsoft.AspNetCore.Http.HttpContext" }, new HeapTypeStatistics() { Count = 1, TotalSize = 1000, TypeName = "Microsoft.AspNetCore.SignalR.HubConnectionContext" }, new HeapTypeStatistics() { Count = 4000, TotalSize = long.MaxValue, TypeName = "System.Byte[]" }, } }; return(View(data)); }
public void PopupShowAsync(Point aLocation, HeapCell aCell, RawItem aItem, HeapStatistics aStats, Size aOffset, System.Windows.Forms.KeyEventHandler aKeyHandler) { //System.Diagnostics.Debug.WriteLine( "PopupBase - Timer Started" ); iKeyHandler = aKeyHandler; HeapCellArrayWithStatistics array = new HeapCellArrayWithStatistics(); array.Add(aCell); PrepareContent(array, aStats, aItem); // iHoverPos = aLocation; // iShowPos = aLocation; iShowPos.Offset(aOffset.Width, aOffset.Height); // If we are using an async timer delay then we must start the timer and // when it expires, the popup will become visible. Otherwise, we show // the popup immediately. if (VisibilityDelay > 0) { iTimer.Stop(); iTimer.Enabled = true; iTimer.Start(); } else { PopupShow(); } }
public static void RunGenerations() { memoryDiff = GC.GetTotalMemory(true); var mocks = new List <Mock>(100); mocks.AddRange(Enumerable.Range(0, 10).Select(x => new Mock((char)((byte)'A' + x)))); HeapStatistics.CollectAndReport(mocks, () => { mocks.RemoveAt(1); mocks.RemoveAt(5); mocks.RemoveAt(6); }); mocks.Add(new Mock('X')); mocks.Add(new Mock('Y')); mocks.Add(new Mock('Z')); HeapStatistics.CollectAndReport(mocks, () => { mocks.RemoveAt(2); mocks.RemoveAt(4); mocks.RemoveAt(1); }); mocks.Add(new Mock('W')); HeapStatistics.CollectAndReport(mocks, () => { mocks.RemoveAt(0); }); }
public void PopupShowAsync(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, Point aLocalControlCoordinates, Point aScreenCoordinates, Size aOffsetBy, System.Windows.Forms.KeyEventHandler aKeyHandler) { lock (this) { PopupShowAsyncImpl(aCells, aStats, aLocalControlCoordinates, aScreenCoordinates, aOffsetBy, aKeyHandler); } }
public static DescriptorInfo DescriptorInfo(HeapCell aCell, HeapStatistics aStats) { DescriptorInfo ret = null; // if (iAlgorithms.Count == 0) { PrepareAlgorithms(aStats); } // foreach (DescriptorAlgorithmBase alg in iAlgorithms) { bool isDes = alg.IsDescriptor(aCell, out ret); if (isDes && ret != null) { // We won't allow any algorithm to "recognise" the heap cell as a descriptor // unless it can say that the length is > 0. int length = ret.Length; if (length > 0) { break; } else { ret = null; } } } return(ret); }
public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, RawItem aRawItem) { try { System.Diagnostics.Debug.Assert(aCells.Count == 1); System.Diagnostics.Debug.Assert(aRawItem.Tag != null && aRawItem.Tag is RelationshipInfo); HeapCell cell = aCells[0]; RelationshipManager relMgr = cell.RelationshipManager; RelationshipInfo relInfo = (RelationshipInfo)aRawItem.Tag; // StringBuilder msg = new StringBuilder(); // msg.AppendFormat("This is an embedded reference to the cell at address 0x{0}", relInfo.ToCell.Address.ToString("x8")); if (relInfo.ToCell.Symbol != null) { msg.AppendFormat(", which is an instance of a {0} object.", relInfo.ToCell.SymbolString); } msg.Append(System.Environment.NewLine + System.Environment.NewLine); // msg.AppendFormat("In total, this cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // iLbl_Description.Text = msg.ToString(); } finally { base.PrepareContent(aCells, aStats, aRawItem); } }
public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats) { try { HeapCell cell = aCells[0]; System.Diagnostics.Debug.Assert(cell.Type == HeapCell.TType.EAllocated); System.Diagnostics.Debug.Assert(cell.Symbol != null); RelationshipManager relMgr = cell.RelationshipManager; // TrackingInfo info = aStats.StatsAllocated.TrackerSymbols[cell.Symbol]; int instCount = info.AssociatedCellCount; // Title = instCount + " Instance(s)"; // StringBuilder msg = new StringBuilder(); // msg.AppendFormat("This allocated cell is an instance of {0} from {1}", cell.Symbol.NameWithoutVTablePrefix, cell.Symbol.ObjectWithoutSection); msg.Append(System.Environment.NewLine + System.Environment.NewLine); msg.AppendFormat("There {0} {1} instance{2} of this symbol, with each instance using {3} bytes of memory (plus cell header overhead).", (instCount == 0 || instCount > 1) ? "are" : "is", info.AssociatedCellCount, (instCount == 0 || instCount > 1) ? "s" : string.Empty, cell.PayloadLength); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // msg.AppendFormat("In total, cells of this type use {0} bytes of heap memory", info.AssociatedMemory); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // msg.AppendFormat("This cell references {0} other cell(s), and is referenced by {1} cell(s)", relMgr.EmbeddedReferencesTo.Count, relMgr.ReferencedBy.Count); msg.Append(System.Environment.NewLine + System.Environment.NewLine); // iLbl_Description.Text = msg.ToString(); } finally { base.PrepareContent(aCells, aStats); } }
public override void PopupShowAsyncImpl(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, Point aLocalControlCoordinates, Point aScreenCoordinates, Size aOffsetBy, System.Windows.Forms.KeyEventHandler aKeyHandler) { PopupHide(); // if (aCells.Count == 1) { HeapCell cell = aCells[0]; // switch (cell.Type) { default: case HeapCell.TType.EAllocated: if (cell.Symbol != null) { iActivePopup = new PopupCellAllocatedSymbols(); } else { iActivePopup = new PopupCellAllocatedRaw(); } break; case HeapCell.TType.EFree: iActivePopup = new PopupCellFree(); break; } } else if (aCells.Count > 1) { iActivePopup = new PopupMultiCellSelection(); iActivePopup.VisibilityDelay = 0; } // iActivePopup.PopupShowAsync(aScreenCoordinates, aCells, aStats, aOffsetBy, aKeyHandler); }
public override void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats) { try { Title = aCells.Count + " Cells Selected"; StringBuilder msg = new StringBuilder(); // if (aCells.Statistics.StatsAllocated.TypeCount > 0) { msg.AppendFormat("Selection contains {0} allocated cell{1}", aCells.Statistics.StatsAllocated.TypeCount, (aCells.Statistics.StatsAllocated.TypeCount == 1) ? string.Empty : "s"); if (aCells.Statistics.StatsAllocated.TrackerDescriptors.AssociatedCellCount > 0) { msg.AppendFormat(", {0} descriptor{1}", aCells.Statistics.StatsAllocated.TrackerDescriptors.AssociatedCellCount, (aCells.Statistics.StatsAllocated.TrackerDescriptors.AssociatedCellCount == 1) ? string.Empty : "s"); } if (aCells.Statistics.StatsAllocated.TrackerSymbols.Count > 0) { msg.AppendFormat(" and {0} symbol instance{1}", aCells.Statistics.StatsAllocated.TrackerSymbols.Count, (aCells.Statistics.StatsAllocated.TrackerSymbols.Count == 1) ? string.Empty : "s"); msg.AppendFormat(" from {0} different object{1}", aCells.Statistics.StatsAllocated.TrackerObjects.Count, (aCells.Statistics.StatsAllocated.TrackerObjects.Count == 1) ? string.Empty : "s"); } msg.Append("."); msg.Append(System.Environment.NewLine + System.Environment.NewLine); if (aCells.Statistics.StatsAllocated.CellSmallest != null) { msg.AppendFormat("The smallest allocated cell is {0} bytes long. ", aCells.Statistics.StatsAllocated.CellSmallest.Length); } if (aCells.Statistics.StatsAllocated.CellLargest != null && (aCells.Statistics.StatsAllocated.CellSmallest.Address != aCells.Statistics.StatsAllocated.CellLargest.Address)) { msg.AppendFormat("The largest allocated cell is {0} bytes long. ", aCells.Statistics.StatsAllocated.CellLargest.Length); } msg.Append(System.Environment.NewLine + System.Environment.NewLine); } if (aCells.Statistics.StatsFree.TypeCount > 0) { msg.AppendFormat("Selection contains {0} free cell{1}", aCells.Statistics.StatsFree.TypeCount, (aCells.Statistics.StatsFree.TypeCount == 1) ? string.Empty : "s"); msg.Append("."); msg.Append(System.Environment.NewLine + System.Environment.NewLine); if (aCells.Statistics.StatsFree.CellSmallest != null) { msg.AppendFormat("The smallest free cell is {0} bytes long. ", aCells.Statistics.StatsFree.CellSmallest.Length); } if (aCells.Statistics.StatsFree.CellLargest != null && (aCells.Statistics.StatsFree.CellSmallest.Address != aCells.Statistics.StatsFree.CellLargest.Address)) { msg.AppendFormat("The largest free cell is {0} bytes long. ", aCells.Statistics.StatsFree.CellLargest.Length); } } iLbl_Description.Text = msg.ToString(); } finally { base.PrepareContent(aCells, aStats); } }
public void PopupShowAsync(HeapCell aCell, RawItem aItem, HeapStatistics aStats, Point aLocalControlCoordinates, Point aScreenCoordinates, Size aOffsetBy, System.Windows.Forms.KeyEventHandler aKeyHandler) { if (SupportsRawItemInfo) { lock (this) { PopupShowAsyncImpl(aCell, aItem, aStats, aLocalControlCoordinates, aScreenCoordinates, aOffsetBy, aKeyHandler); } } }
public override void PopupShowAsyncImpl(HeapCell aCell, RawItem aItem, HeapStatistics aStats, Point aLocalControlCoordiantes, Point aScreenCoordinates, Size aOffsetBy, KeyEventHandler aKeyHandler) { PopupHide(); // System.Diagnostics.Debug.Assert(aItem.Tag != null && aItem.Tag is RelationshipInfo); // iActivePopup = new PopupCellRelationshipInfo(); iActivePopup.ColourFromHoverCoordinate = true; iActivePopup.PopupShowAsync(aScreenCoordinates, aCell, aItem, aStats, aOffsetBy, aKeyHandler); }
public void PopupRelocate(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, Point aLocalControlCoordiantes, Point aScreenCoordinates, Size aOffsetBy) { if (iActivePopup != null && Visible) { lock (this) { iActivePopup.PopupRelocate(aScreenCoordinates, aCells, aStats, aOffsetBy); } } }
private static void PrepareAlgorithms(HeapStatistics aStats) { // UNICODE iAlgorithms.Add(new DesUnicodeAlgorithmHBufC(aStats)); iAlgorithms.Add(new DesUnicodeAlgorithmModifiableBuffers(aStats)); // ASCII iAlgorithms.Add(new DesAsciiAlgorithmHBufC(aStats)); iAlgorithms.Add(new DesAsciiAlgorithmModifiableBuffers(aStats)); // C-STRING iAlgorithms.Add(new DesAsciiAlgorithmNullTerminatedString(aStats)); }
private void LoadHeapStatistics() { HeapStatistics.Clear(); _cperfContainer.GarbageCollectorGenerations.ForEach( x => HeapStatistics.Add( new MemoryData() { Timestamp = x.Timestamp, LargeObjectsHeap = x.LargeObjectsHeap, SmallObjectsHeapGeneration0 = x.SmallObjectsHeapGeneration0, SmallObjectsHeapGeneration1 = x.SmallObjectsHeapGeneration1, SmallObjectsHeapGeneration2 = x.SmallObjectsHeapGeneration2 }) ); }
public void Run(AnalysisSession analysisSession, string[] arguments) { var groups = analysisSession.Context.Runtime.Heap.EnumerateObjects().GroupBy(o => o.Type.Name).ToList(); var heapStats = new HeapStatistics() { TotalUniqueObjects = groups.Count, Types = groups.Select(g => { var objs = g.ToList(); return(new HeapTypeStatistics() { TypeName = new TypeRef(g.Key), Count = objs.Count, TotalSize = objs.Aggregate(0ul, (l, o) => l + o.Size) }); }).OrderByDescending(t => t.TotalSize) }; analysisSession.Reporter.Write(heapStats); }
public override void PopupShowAsyncImpl(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, Point aLocalControlCoordinates, Point aScreenCoordinates, Size aCellBoxSizeIncludingPadding, System.Windows.Forms.KeyEventHandler aKeyHandler) { PopupHide(); // if (aCells.Count == 1) { HeapCell cell = aCells[0]; // If there's a free cell with a symbol (possible, if the user wanted to decode free cell contents) // then we should just display the allocated symbol popup (even though it's a free cell!) if (cell.Symbol != null) { if (cell.Type == HeapCell.TType.EFree) { int x = 0; x++; } iActivePopup = new PopupCellAllocatedSymbols(); } else if (cell.Type == HeapCell.TType.EAllocated) { iActivePopup = new PopupCellAllocatedRaw(); } else if (cell.Type == HeapCell.TType.EFree) { iActivePopup = new PopupCellFree(); } iActivePopup.ColourFromHoverCoordinate = true; } else if (aCells.Count > 1) { iActivePopup = new PopupMultiCellSelection(); iActivePopup.VisibilityDelay = 0; } // iActivePopup.PopupShowAsync(aScreenCoordinates, aCells, aStats, aCellBoxSizeIncludingPadding, aKeyHandler); }
public RHeapExtractor(DataSource aDataSource, Options aOptions, DbgEngine aDebugEngine, RelationshipInspector aRelationshipInspector, HeapStatistics aStatistics, HeapCellArray aData) { iData = aData; iOptions = aOptions; iStatistics = aStatistics; iDataSource = aDataSource; iDebugEngine = aDebugEngine; iState = new ExtractionState(aDataSource); iRelationshipInspector = aRelationshipInspector; // HeapCell.AllocatedCellHeaderSize = AllocatedCellHeaderSize; // Must prime these iState.NextFreeCellAddress = aDataSource.MetaData.Heap.InfoFree.FreeCellAddress; iState.NextFreeCellLength = aDataSource.MetaData.Heap.InfoFree.FreeCellLength; // if (iState.NextFreeCellAddress == 0) { throw new ArgumentException("Next free cell information invalid"); } //iState.DebugEnabled = true; }
public DesAsciiAlgorithmBase(HeapStatistics aStats) : base(aStats) { }
public DesAsciiAlgorithmNullTerminatedString(HeapStatistics aStats) : base(aStats) { }
private void MakeStats(ref int aRow) { Utils.SetValue(aRow, 1, Worksheet, "Type"); Utils.SetValue(aRow, 2, Worksheet, "Amount"); // Make row bold Utils.BoldRow(aRow, Worksheet); // Add border and cell colours Utils.MakeBoxedTitleRow(aRow, 2, Worksheet, 0xFF0000); // Set column alignments Utils.SetColumnHorizontalAlignment(2, Worksheet, XlHAlign.xlHAlignRight); // Spacer aRow++; int firstRealRow = aRow; HeapStatistics stats = Array.Statistics; { Utils.SetValue(aRow, 1, Worksheet, "Total"); Utils.SetValue(aRow, 2, Worksheet, stats.SizeTotal.ToString()); } // Spacer aRow++; { aRow++; Utils.SetValue(aRow, 1, Worksheet, "Allocated Space"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TypeSize.ToString()); aRow++; Utils.SetValue(aRow, 1, Worksheet, "Allocated Cell Count"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TypeCount.ToString()); } // Spacer aRow++; { aRow++; Utils.SetValue(aRow, 1, Worksheet, "\"Unknown\" Allocated Space"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerUnknown.AssociatedMemory.ToString()); aRow++; Utils.SetValue(aRow, 1, Worksheet, "\"Unknown\" Allocated Cell Count"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerUnknown.AssociatedCellCount.ToString()); } // Spacer aRow++; { aRow++; Utils.SetValue(aRow, 1, Worksheet, "Descriptor Allocated Space"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerDescriptors.AssociatedMemory.ToString()); aRow++; Utils.SetValue(aRow, 1, Worksheet, "Descriptor Allocated Cell Count"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerDescriptors.AssociatedCellCount.ToString()); } // Spacer aRow++; { aRow++; Utils.SetValue(aRow, 1, Worksheet, "\"With Symbols\" Allocated Space"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerSymbols.TypeSize.ToString()); aRow++; Utils.SetValue(aRow, 1, Worksheet, "\"With Symbols\" Allocated Cell Count"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsAllocated.TrackerSymbols.CellMatchCount.ToString()); } // Spacer aRow++; int freeaRow = aRow; { aRow++; Utils.SetValue(aRow, 1, Worksheet, "Free Space"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsFree.TypeSize.ToString()); aRow++; Utils.SetValue(aRow, 1, Worksheet, "Free Cell Count"); Utils.SetValue(aRow, 2, Worksheet, stats.StatsFree.TypeCount.ToString()); } Utils.GetRangeByColumnAndRow(firstRealRow, 1, aRow, 1, Worksheet).Font.Bold = true; // Spacer aRow++; aRow++; }
public virtual void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats, RawItem aRawItem) { PrepareContent(aCells, aStats); }
public virtual void PrepareContent(HeapCellArrayWithStatistics aCells, HeapStatistics aStats) { // Set title and border colour HeapCell firstCell = aCells[0]; ColourTitle = HeapCtrlLib.Renderers.Utilities.HeapCellRendererColour.ColourByCellType(firstCell); ColourBorder = ColourUtils.Darken(ColourTitle); // Get stats long lengthPayload = aCells.Statistics.SizeTotalPayload; long lengthHeader = aCells.Statistics.SizeTotalHeader; float lengthsAsHeapPercentage = aStats.CellLengthAsHeapPercentage(lengthHeader + lengthPayload); // Header length iLbl_Title_Length_Header.Text = "H: [" + lengthHeader.ToString("d6") + "]"; // Payload length iLbl_Title_Length_Payload.Text = "P: [" + lengthPayload.ToString("d8") + "]"; // Set cell allocation number (for allocated cells) or then // the cell index for free cells. string heapSpecificPrefix = "H: "; if (aCells.Count == 1) { float lengthsAsTypePercentage = aStats.CellLengthAsTypePercentage(firstCell); // string typeSpecificPrefix = "A: "; if (firstCell.Type == HeapCell.TType.EFree) { typeSpecificPrefix = "F: "; } // if (HeapCell.IsDebugAllocator) { switch (firstCell.Type) { case HeapCell.TType.EAllocated: iLbl_Footer.Text = "Alloc #: [" + firstCell.AllocationNumber.ToString("d6") + " / " + aStats.StatsAllocated.CellAllocationNumberLargest.AllocationNumber.ToString("d6") + "]"; break; case HeapCell.TType.EFree: iLbl_Footer.Text = "Free cell #: [" + firstCell.AllocationNumber.ToString("d4") + " / " + aStats.StatsFree.TypeCount.ToString("d4") + "]"; break; } } else { iLbl_Footer.Text = "[ " + firstCell.Address.ToString("x8") + " ]"; } // iLbl_Footer_Percentage_OfType.Text = typeSpecificPrefix + "[" + lengthsAsTypePercentage.ToString("#00.00") + "%]"; } else { heapSpecificPrefix = "Of Heap: "; iLbl_Footer.Text = string.Empty; iLbl_Footer_Percentage_OfType.Visible = false; } // iLbl_Footer_Percentage_OfTotal.Text = heapSpecificPrefix + "[" + lengthsAsHeapPercentage.ToString("#00.00") + "%]"; }
public void PopupRelocate(Point aLocation, HeapCellArrayWithStatistics aCells, HeapStatistics aStats, Size aOffset) { PrepareContent(aCells, aStats); Invalidate(); iShowPos = aLocation; iShowPos.Offset(aOffset.Width, aOffset.Height); // Get the screen size Rectangle rect = Screen.GetWorkingArea(this); // Make sure that the popup is displayed within the screen bounds. Point pos = iShowPos; if (iShowPos.X + this.Width > rect.Right) { pos.X = rect.Width - this.Width; } if (iShowPos.Y + this.Height > rect.Bottom) { pos.Y = rect.Bottom - this.Height; } Location = pos; }
public DesUnicodeAlgorithmHBufC(HeapStatistics aStats) : base(aStats) { }
protected DescriptorAlgorithmBase(HeapStatistics aStats) { iStats = aStats; }
public virtual void PopupShowAsyncImpl(HeapCell aCell, RawItem aItem, HeapStatistics aStats, Point aLocalControlCoordiantes, Point aScreenCoordinates, Size aOffsetBy, System.Windows.Forms.KeyEventHandler aKeyHandler) { }
public DesAsciiAlgorithmModifiableBuffers(HeapStatistics aStats) : base(aStats) { }
public RelationshipInspector(HeapCellArray aEntries, HeapStatistics aStats) : base(null) { iEntries = aEntries; iStats = aStats; }