internal static Histogram GetSurvivorHistogram(ReadNewLog log, ReadLogResult entireLogResult, int startTickIndex, int endTickIndex, string timeMarker) { ReadLogResult logResult = entireLogResult; int timeTickIndex = entireLogResult.sampleObjectTable.lastTickIndex; if (timeMarker != null) { timeTickIndex = FindMarkerTickIndex(timeMarker, log); long endPos = log.TickIndexToPos(timeTickIndex); // Read the selected portion of the log again logResult = new ReadLogResult(); logResult.liveObjectTable = new LiveObjectTable(log); log.ReadFile(0, endPos, logResult); } Histogram histogram = new Histogram(log); LiveObjectTable.LiveObject o; for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue; logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o)) { if (startTickIndex <= o.allocTickIndex && o.allocTickIndex < endTickIndex) { histogram.AddObject(o.typeSizeStacktraceIndex, 1); } } return(histogram); }
private void showHistogramMenuItem_Click(object sender, System.EventArgs e) { TypeDesc selectedType = FindSelectedType(); // Create a new histogram and add all the objects in the selected address range // whose type matches the selected type (if any). ReadNewLog log = liveObjectTable.readNewLog; var histogram = new Histogram(log); ulong low = selectedLowAddr; ulong high = low == 0 ? ulong.MaxValue : selectedHighAddr; LiveObjectTable.LiveObject o; for (liveObjectTable.GetNextObject(low, high, out o); o.id < high; liveObjectTable.GetNextObject(o.id + o.size, high, out o)) { if (selectedType == null || selectedType.typeIndex == o.typeIndex) { histogram.AddObject(o.typeSizeStacktraceIndex, 1); } } string title = "Histogram by Size for live " + ComputeObjectsDescription(selectedType, selectedLowAddr, selectedHighAddr); var histogramViewForm = new HistogramViewForm(histogram, title); histogramViewForm.Show(); }
internal void UpdateObjects(Histogram relocatedHistogram, ulong oldId, ulong newId, uint length, int tickIndex, SampleObjectTable sampleObjectTable) { if (lastPos >= readNewLog.pos) { return; } lastPos = readNewLog.pos; lastTickIndex = tickIndex; intervalTable.Relocate(oldId, newId, length); if (oldId == newId) { return; } ulong nextId; ulong lastId = oldId + length; LiveObject o; for (GetNextObject(oldId, lastId, out o); o.id < lastId; GetNextObject(nextId, lastId, out o)) { nextId = o.id + o.size; ulong offset = o.id - oldId; sampleObjectTable?.Delete(o.id, o.id + o.size, tickIndex); Zero(o.id, o.size); InsertObject(newId + offset, o.typeSizeStacktraceIndex, o.allocTickIndex, tickIndex, false, sampleObjectTable); relocatedHistogram?.AddObject(o.typeSizeStacktraceIndex, 1); } }
private void showAllocatorsMenuItem_Click(object sender, System.EventArgs e) { TypeDesc selectedType = FindSelectedType(); // Create a new allocation graph and add all the objects in the selected address range // whose type matches the selected type (if any). ReadNewLog log = liveObjectTable.readNewLog; var histogram = new Histogram(log); ulong low = selectedLowAddr; ulong high = low == 0 ? ulong.MaxValue : selectedHighAddr; LiveObjectTable.LiveObject o; for (liveObjectTable.GetNextObject(low, high, out o); o.id < high; liveObjectTable.GetNextObject(o.id + o.size, high, out o)) { if (selectedType == null || selectedType.typeIndex == o.typeIndex) { histogram.AddObject(o.typeSizeStacktraceIndex, 1); } } // Build the real graph from the histogram Graph graph = histogram.BuildAllocationGraph(new FilterForm()); // And make another graph form for it - hardest part is to compute an appropriate title... string title = "Allocation Graph for live " + ComputeObjectsDescription(selectedType, selectedLowAddr, selectedHighAddr); var graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
private void showWhoAllocatedMenuItem_Click(object sender, System.EventArgs e) { Histogram selectedHistogram; string title; TypeDesc selectedType = FindSelectedType(); if (selectedType == null) { title = "Allocation Graph"; selectedHistogram = histogram; } else { int minSize = 0; int maxSize = int.MaxValue; foreach (Bucket b in buckets) { if (b.selected) { minSize = b.minSize; maxSize = b.maxSize; } } title = string.Format("Allocation Graph for {0} objects", selectedType.typeName); if (minSize > 0) { title += string.Format(" of size between {0:n0} and {1:n0} bytes", minSize, maxSize); } selectedHistogram = new Histogram(histogram.readNewLog); for (int i = 0; i < histogram.typeSizeStacktraceToCount.Length; i++) { int count = histogram.typeSizeStacktraceToCount[i]; if (count > 0) { int[] stacktrace = histogram.readNewLog.stacktraceTable.IndexToStacktrace(i); int typeIndex = stacktrace[0]; int size = stacktrace[1]; if (minSize <= size && size <= maxSize) { var t = (TypeDesc)typeIndexToTypeDesc[typeIndex]; if (t == selectedType) { selectedHistogram.AddObject(i, count); } } } } } Graph graph = selectedHistogram.BuildAllocationGraph(new FilterForm()); var graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
private void showWhoAllocatedMenuItem_Click(object sender, System.EventArgs e) { TypeDesc selectedType = FindSelectedType(); double minAge = 0; double maxAge = double.PositiveInfinity; Debug.Assert(bucketTable != null, "bucketTable != null"); foreach (Bucket b in bucketTable) { if (b.selected) { minAge = b.minAge; maxAge = b.maxAge; } } string title = "Allocation Graph for objects"; if (selectedType != null) { title = string.Format("Allocation Graph for {0} objects", selectedType.typeName); } if (minAge > 0.0) { title += string.Format(" of age between {0} and {1} seconds", FormatTime(minAge), FormatTime(maxAge)); } Debug.Assert(liveObjectTable != null, "liveObjectTable != null"); var selectedHistogram = new Histogram(liveObjectTable.readNewLog); LiveObjectTable.LiveObject o; double nowTime = liveObjectTable.readNewLog.TickIndexToTime(liveObjectTable.lastTickIndex); Debug.Assert(typeIndexToTypeDesc != null, "typeIndexToTypeDesc != null"); for (liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue; liveObjectTable.GetNextObject(o.id + o.size, uint.MaxValue, out o)) { double age = nowTime - liveObjectTable.readNewLog.TickIndexToTime(o.allocTickIndex); if (minAge <= age && age < maxAge) { var t = (TypeDesc)typeIndexToTypeDesc[o.typeIndex]; if (selectedType == null || t == selectedType) { selectedHistogram.AddObject(o.typeSizeStacktraceIndex, 1); } } } Graph graph = selectedHistogram.BuildAllocationGraph(new FilterForm()); var graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
private void survingHandlesAllocationGraphButton_Click(object sender, System.EventArgs e) { var histogram = new Histogram(log); foreach (HandleInfo handleInfo in logResult.handleHash.Values) { histogram.AddObject(handleInfo.allocStacktraceId, 1); } string title = "Surviving Handle Allocation Graph for: " + scenario; CreateHandleAllocationGraph(histogram, title); }
private Histogram GetFinalHeapHistogram() { var histogram = new Histogram(log); LiveObjectTable.LiveObject o; for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue && o.id + o.size >= o.id; logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o)) { histogram.AddObject(o.typeSizeStacktraceIndex, 1); } return(histogram); }
private Histogram MakeHistogram(int allocatedAfterTickIndex, int allocatedBeforeTickIndex) { // Build a histogram of types, sizes, allocation stacks from the object graph, // using only the objects whose vertices are selected // First of all, limit the interval to the one of the underlying graph if (allocatedAfterTickIndex < graph.allocatedAfterTickIndex) allocatedAfterTickIndex = graph.allocatedAfterTickIndex; if (allocatedBeforeTickIndex > graph.allocatedBeforeTickIndex) allocatedBeforeTickIndex = graph.allocatedBeforeTickIndex; Graph originalGraph = GetOriginalGraph(); ObjectGraph objectGraph = GetObjectGraph(); Histogram histogram = new Histogram(objectGraph.readNewLog); bool anyVertexSelected = SelectedVertexCount() != 0; foreach (KeyValuePair<ulong, ObjectGraph.GcObject> keyValuePair in objectGraph.idToObject) { ulong id = keyValuePair.Key; ObjectGraph.GcObject gcObject = keyValuePair.Value; if (gcObject.TypeSizeStackTraceId > 0 && gcObject.AllocTickIndex > allocatedAfterTickIndex && gcObject.AllocTickIndex < allocatedBeforeTickIndex && gcObject.InterestLevel != InterestLevel.Ignore) { if (anyVertexSelected || originalGraph != graph) { gcObject.vertex = null; Vertex v = objectGraph.FindVertex(id, gcObject, originalGraph, ObjectGraph.BuildTypeGraphOptions.LumpBySignature); if (originalGraph != graph) { v = graph.FindVertex(v.name, v.signature, v.moduleName); if (v == null) continue; } if (anyVertexSelected && !v.selected) continue; } histogram.AddObject(gcObject.TypeSizeStackTraceId, 1); } } return histogram; }
private void showHistogramMenuItem_Click(object sender, System.EventArgs e) { TypeDesc selectedType = FindSelectedType(); // Create a new histogram and add all the objects in the selected address range // whose type matches the selected type (if any). ReadNewLog log = liveObjectTable.readNewLog; Histogram histogram = new Histogram(log); ulong low = selectedLowAddr; ulong high = low == 0 ? ulong.MaxValue : selectedHighAddr; LiveObjectTable.LiveObject o; for (liveObjectTable.GetNextObject(low, high, out o); o.id < high; liveObjectTable.GetNextObject(o.id + o.size, high, out o)) { if (selectedType == null || selectedType.typeIndex == o.typeIndex) histogram.AddObject(o.typeSizeStacktraceIndex, 1); } string title = "Histogram by Size for live " + ComputeObjectsDescription(selectedType, selectedLowAddr, selectedHighAddr); HistogramViewForm histogramViewForm = new HistogramViewForm(histogram, title); histogramViewForm.Show(); }
private void showWhoAllocatedMenuItem_Click(object sender, System.EventArgs e) { Histogram selectedHistogram; string title; TypeDesc selectedType = FindSelectedType(); if (selectedType == null) { title = "Allocation Graph"; selectedHistogram = histogram; } else { int minSize = 0; int maxSize = int.MaxValue; foreach (Bucket b in buckets) { if (b.selected) { minSize = b.minSize; maxSize = b.maxSize; } } title = string.Format("Allocation Graph for {0} objects", selectedType.typeName); if (minSize > 0) title += string.Format(" of size between {0:n0} and {1:n0} bytes", minSize, maxSize); selectedHistogram = new Histogram(histogram.readNewLog); for (int i = 0; i < histogram.typeSizeStacktraceToCount.Length; i++) { int count = histogram.typeSizeStacktraceToCount[i]; if (count > 0) { int[] stacktrace = histogram.readNewLog.stacktraceTable.IndexToStacktrace(i); int typeIndex = stacktrace[0]; int size = stacktrace[1]; if (minSize <= size && size <= maxSize) { TypeDesc t = (TypeDesc)typeIndexToTypeDesc[typeIndex]; if (t == selectedType) { selectedHistogram.AddObject(i, count); } } } } } Graph graph = selectedHistogram.BuildAllocationGraph(new FilterForm()); GraphViewForm graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
internal static Histogram GetSurvivorHistogram(ReadNewLog log, ReadLogResult entireLogResult, int startTickIndex, int endTickIndex, string timeMarker) { ReadLogResult logResult = entireLogResult; int timeTickIndex = entireLogResult.sampleObjectTable.lastTickIndex; if (timeMarker != null) { timeTickIndex = FindMarkerTickIndex(timeMarker, log); long endPos = log.TickIndexToPos(timeTickIndex); // Read the selected portion of the log again logResult = new ReadLogResult(); logResult.liveObjectTable = new LiveObjectTable(log); log.ReadFile(0, endPos, logResult); } Histogram histogram = new Histogram(log); LiveObjectTable.LiveObject o; for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue; logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o)) { if (startTickIndex <= o.allocTickIndex && o.allocTickIndex < endTickIndex) histogram.AddObject(o.typeSizeStacktraceIndex, 1); } return histogram; }
private void showAllocatorsMenuItem_Click(object sender, System.EventArgs e) { TypeDesc selectedType = FindSelectedType(); // Create a new allocation graph and add all the objects in the selected address range // whose type matches the selected type (if any). ReadNewLog log = liveObjectTable.readNewLog; Histogram histogram = new Histogram(log); ulong low = selectedLowAddr; ulong high = low == 0 ? ulong.MaxValue : selectedHighAddr; LiveObjectTable.LiveObject o; for (liveObjectTable.GetNextObject(low, high, out o); o.id < high; liveObjectTable.GetNextObject(o.id + o.size, high, out o)) { if (selectedType == null || selectedType.typeIndex == o.typeIndex) histogram.AddObject(o.typeSizeStacktraceIndex, 1); } // Build the real graph from the histogram Graph graph = histogram.BuildAllocationGraph(new FilterForm()); // And make another graph form for it - hardest part is to compute an appropriate title... string title = "Allocation Graph for live " + ComputeObjectsDescription(selectedType, selectedLowAddr, selectedHighAddr); GraphViewForm graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
internal void UpdateObjects(Histogram relocatedHistogram, ulong oldId, ulong newId, uint length, int tickIndex, SampleObjectTable sampleObjectTable) { if (lastPos >= readNewLog.pos) return; lastPos = readNewLog.pos; lastTickIndex = tickIndex; intervalTable.Relocate(oldId, newId, length); if (oldId == newId) return; ulong nextId; ulong lastId = oldId + length; LiveObject o; for (GetNextObject(oldId, lastId, out o); o.id < lastId; GetNextObject(nextId, lastId, out o)) { nextId = o.id + o.size; ulong offset = o.id - oldId; if (sampleObjectTable != null) sampleObjectTable.Delete(o.id, o.id + o.size, tickIndex); Zero(o.id, o.size); InsertObject(newId + offset, o.typeSizeStacktraceIndex, o.allocTickIndex, tickIndex, false, sampleObjectTable); if (relocatedHistogram != null) relocatedHistogram.AddObject(o.typeSizeStacktraceIndex, 1); } }
private Histogram GetLiveHistogram() { LiveObjectTable liveObjectTable = GetLiveObjectTable(); Histogram histogram = new Histogram(sampleObjectTable.readNewLog); LiveObjectTable.LiveObject o; for (liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue; liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o)) { if (firstAllocTickIndex <= o.allocTickIndex && o.allocTickIndex < lastAllocTickIndex) histogram.AddObject(o.typeSizeStacktraceIndex, 1); } return histogram; }
private void showWhoAllocatedMenuItem_Click(object sender, System.EventArgs e) { Histogram selectedHistogram; string title; TypeDesc selectedType = FindSelectedType(); double minAge = 0; double maxAge = double.PositiveInfinity; foreach (Bucket b in bucketTable) { if (b.selected) { minAge = b.minAge; maxAge = b.maxAge; } } title = "Allocation Graph for objects"; if (selectedType != null) title = string.Format("Allocation Graph for {0} objects", selectedType.typeName); if (minAge > 0.0) title += string.Format(" of age between {0} and {1} seconds", FormatTime(minAge), FormatTime(maxAge)); selectedHistogram = new Histogram(liveObjectTable.readNewLog); LiveObjectTable.LiveObject o; double nowTime = liveObjectTable.readNewLog.TickIndexToTime(liveObjectTable.lastTickIndex); for (liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue; liveObjectTable.GetNextObject(o.id + o.size, uint.MaxValue, out o)) { double age = nowTime - liveObjectTable.readNewLog.TickIndexToTime(o.allocTickIndex); if (minAge <= age && age < maxAge) { TypeDesc t = (TypeDesc)typeIndexToTypeDesc[o.typeIndex]; if (selectedType == null || t == selectedType) { selectedHistogram.AddObject(o.typeSizeStacktraceIndex, 1); } } } Graph graph = selectedHistogram.BuildAllocationGraph(new FilterForm()); GraphViewForm graphViewForm = new GraphViewForm(graph, title); graphViewForm.Visible = true; }
private void survingHandlesAllocationGraphButton_Click(object sender, System.EventArgs e) { Histogram histogram = new Histogram(log); foreach (HandleInfo handleInfo in logResult.handleHash.Values) { histogram.AddObject(handleInfo.allocStacktraceId, 1); } string title = "Surviving Handle Allocation Graph for: " + scenario; CreateHandleAllocationGraph(histogram, title); }
private Histogram GetFinalHeapHistogram() { Histogram histogram = new Histogram(log); LiveObjectTable.LiveObject o; for (logResult.liveObjectTable.GetNextObject(0, ulong.MaxValue, out o); o.id < ulong.MaxValue && o.id + o.size >= o.id; logResult.liveObjectTable.GetNextObject(o.id + o.size, ulong.MaxValue, out o)) { histogram.AddObject(o.typeSizeStacktraceIndex, 1); } return histogram; }