Beispiel #1
0
        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;
        }
Beispiel #2
0
        private void CreateHandleAllocationGraph(Histogram histogram, string title)
        {
            Graph graph         = histogram.BuildHandleAllocationGraph(new FilterForm());
            var   graphViewForm = new GraphViewForm(graph, title);

            graphViewForm.Show();
        }
Beispiel #3
0
        private void allocationGraphButton_Click(object sender, System.EventArgs e)
        {
            Graph  graph         = logResult.allocatedHistogram.BuildAllocationGraph(new FilterForm());
            string title         = "Allocation Graph for: " + scenario;
            var    graphViewForm = new GraphViewForm(graph, title);

            graphViewForm.Show();
        }
Beispiel #4
0
        private void heapGraphButton_Click(object sender, System.EventArgs e)
        {
            Graph  graph         = logResult.objectGraph.BuildTypeGraph(new FilterForm());
            string title         = "Heap Graph for " + scenario;
            var    graphViewForm = new GraphViewForm(graph, title);

            graphViewForm.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)
                        {
                            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;
        }
Beispiel #6
0
        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 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;
        }
 private void ZoomVertex(Vertex v, string titlePrefix)
 {
     toolTip.Active = false;
     Graph g;
     if (graph.graphSource is Graph)
     {
         Graph orgGraph = (Graph)graph.graphSource;
         g = new Graph(orgGraph);
         v = orgGraph.FindOrCreateVertex(v.name, v.signature, v.moduleName);
     }
     else
         g = new Graph(graph);
     g.allocatedAfterTickIndex = graph.allocatedAfterTickIndex;
     g.allocatedBeforeTickIndex = graph.allocatedBeforeTickIndex;
     Vertex vn = CloneVertex(g, v);
     vn.count = v.count;
     if (v.incomingEdges.Count == 0)
     {
         if (v != graph.TopVertex)
             g.FindOrCreateEdge(g.TopVertex, vn).AddWeight(v.weight);
     }
     else
     {
         foreach (Edge e in v.incomingEdges.Values)
         {
             Vertex vin = CloneVertex(g, e.FromVertex);
             g.FindOrCreateEdge(vin, vn).AddWeight(e.weight);
             if (vin != g.TopVertex)
                 g.FindOrCreateEdge(g.TopVertex, vin).AddWeight(e.weight);
         }
     }
     if (v.outgoingEdges.Count == 0)
     {
         if (v != graph.BottomVertex)
             g.FindOrCreateEdge(vn, g.BottomVertex).AddWeight(v.weight);
     }
     else
     {
         foreach (Edge e in v.outgoingEdges.Values)
         {
             Vertex von = CloneVertex(g, e.ToVertex);
             g.FindOrCreateEdge(vn, von).AddWeight(e.weight);
             if (von != g.BottomVertex)
                 g.FindOrCreateEdge(von, g.BottomVertex).AddWeight(e.weight);
         }
     }
     g.BottomVertex.active = false;
     g.graphType = graph.graphType;
     g.typeGraphOptions = graph.typeGraphOptions;
     if (titlePrefix == null)
         titlePrefix = "Zoom to: ";
     string title = titlePrefix + v.name + " " + (v.signature != null? v.signature : "");
     GraphViewForm graphViewForm = new GraphViewForm(g, title);
     graphViewForm.Visible = true;
 }
        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;
        }
        private void whoAllocatedMenuItem_Click(object sender, System.EventArgs e)
        {
            int startTickIndex = 0;
            int endTickIndex = lastTickIndex;
            if (selectedStartTickIndex != 0)
            {
                startTickIndex = selectedStartTickIndex;
                endTickIndex = selectedEndTickIndex;
            }
            Histogram histogram;
            string title;
            if (startTickIndex != 0 && startTickIndex == endTickIndex)
            {
                histogram = GetLiveHistogram();
                title = string.Format("Allocation Graph for Objects at {0:f3} seconds", lastLog.TickIndexToTime(startTickIndex));
            }
            else
            {
                ReadNewLog log = sampleObjectTable.readNewLog;
                long startPos = log.TickIndexToPos(startTickIndex);
                long endPos = log.TickIndexToPos(endTickIndex);

                // Read the selected portion of the log again
                ReadLogResult readLogResult = new ReadLogResult();
                readLogResult.allocatedHistogram = new Histogram(log);
                log.ReadFile(startPos, endPos, readLogResult);
                histogram = readLogResult.allocatedHistogram;
                title = string.Format("Allocation Graph for Objects allocated between {0:f3} and {1:f3} seconds", lastLog.TickIndexToTime(startTickIndex), lastLog.TickIndexToTime(endTickIndex));
            }
            Graph graph = histogram.BuildAllocationGraph(new FilterForm());

            // And post it back to the main form - hardest part is to compute an appropriate title...

            GraphViewForm graphViewForm = new GraphViewForm(graph, title);
            graphViewForm.Visible = true;
        }
 private void showReferencesMenuItem_Click(object sender, System.EventArgs e)
 {
     if (graph.graphType == Graph.GraphType.HeapGraph && SelectedVertexCount() != 0)
     {
         ObjectGraph objectGraph = GetObjectGraph();
         Graph g = objectGraph.BuildReferenceGraph(graph);
         string title = "References to selected objects";
         GraphViewForm graphViewForm = new GraphViewForm(g, title);
         graphViewForm.Visible = true;
     }
 }
        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 showNewObjectsMenuItem_Click(object sender, System.EventArgs e)
        {
            ObjectGraph objectGraph = (ObjectGraph)graph.graphSource;
            Graph g = objectGraph.BuildTypeGraph(graph.previousGraphTickIndex, int.MaxValue, ObjectGraph.BuildTypeGraphOptions.LumpBySignature, filterForm);

            string title = "New Live Objects";
            GraphViewForm graphViewForm = new GraphViewForm(g, title);
            graphViewForm.Visible = true;       
        }
        private void showObjectsAllocatedBetween_Click(object sender, System.EventArgs e)
        {
            CommentRangeForm commentRangeForm = new CommentRangeForm();
            if (commentRangeForm.ShowDialog() == DialogResult.OK)
            {
                ObjectGraph objectGraph = (ObjectGraph)graph.graphSource;
                Graph g = objectGraph.BuildTypeGraph(commentRangeForm.startTickIndex, commentRangeForm.endTickIndex, ObjectGraph.BuildTypeGraphOptions.LumpBySignature, filterForm);

                string title = string.Format("Live Objects Allocated Between {0} and {1}", commentRangeForm.startComment, commentRangeForm.endComment);
                GraphViewForm graphViewForm = new GraphViewForm(g, title);
                graphViewForm.Visible = true;
            }
        }
Beispiel #15
0
        private void ViewGraph(ReadLogResult logResult, string exeName, Graph.GraphType graphType)
        {
            string fileName = log.fileName;
            if (exeName != null)
                fileName = exeName;
            Graph graph = null;
            string title = "";
            switch (graphType)
            {
                case Graph.GraphType.CallGraph:
                    graph = logResult.callstackHistogram.BuildCallGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.CallGraph;
                    title = "Call Graph for: ";
                    break;

                case Graph.GraphType.AssemblyGraph:
                    graph = logResult.callstackHistogram.BuildAssemblyGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.AssemblyGraph;
                    title = "Assembly Graph for: ";
                    break;

                case Graph.GraphType.AllocationGraph:
                    graph = logResult.allocatedHistogram.BuildAllocationGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.AllocationGraph;
                    title = "Allocation Graph for: ";
                    break;

                case Graph.GraphType.HeapGraph:
                    graph = logResult.objectGraph.BuildTypeGraph(new FilterForm());
                    title = "Heap Graph for: ";
                    break;

                case Graph.GraphType.FunctionGraph:
                    graph = logResult.functionList.BuildFunctionGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.FunctionGraph;
                    title = "Function Graph for: ";
                    break;

                case Graph.GraphType.ModuleGraph:
                    graph = logResult.functionList.BuildModuleGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.ModuleGraph;
                    title = "Module Graph for: ";
                    break;

                case Graph.GraphType.ClassGraph:
                    graph = logResult.functionList.BuildClassGraph(new FilterForm());
                    graph.graphType = Graph.GraphType.ClassGraph;
                    title = "Class Graph for: ";
                    break;

                default:
                    Debug.Assert(false);
                    break;
            }
            title += fileName + " " + commandLine;
            GraphViewForm graphViewForm = new GraphViewForm(graph, title);
            graphViewForm.Visible = true;
        }
        private void ShowWhoAllocated(string title, int allocatedAfterTickIndex, int allocatedBeforeTickIndex)
        {
            Histogram histogram = MakeHistogram(allocatedAfterTickIndex, allocatedBeforeTickIndex);

            // Build the real graph from the histogram

            Graph g = histogram.BuildAllocationGraph(filterForm);

            GraphViewForm graphViewForm = new GraphViewForm(g, title);
            graphViewForm.Visible = true;
        }
        internal void ViewGraph(ReadLogResult logResult, string exeName, Graph.GraphType graphType)
        {
            string fileName = log.fileName;

            if (exeName != null)
            {
                fileName = exeName;
            }
            Graph  graph = null;
            string title = "";

            switch (graphType)
            {
            case Graph.GraphType.CallGraph:
                graph           = logResult.callstackHistogram.BuildCallGraph(new FilterForm());
                graph.graphType = Graph.GraphType.CallGraph;
                title           = "Call Graph for: ";
                break;

            case Graph.GraphType.AssemblyGraph:
                graph           = logResult.callstackHistogram.BuildAssemblyGraph(new FilterForm());
                graph.graphType = Graph.GraphType.AssemblyGraph;
                title           = "Assembly Graph for: ";
                break;

            case Graph.GraphType.AllocationGraph:
                graph           = logResult.allocatedHistogram.BuildAllocationGraph(new FilterForm());
                graph.graphType = Graph.GraphType.AllocationGraph;
                title           = "Allocation Graph for: ";
                break;

            case Graph.GraphType.HeapGraph:
                graph = logResult.objectGraph.BuildTypeGraph(new FilterForm());
                title = "Heap Graph for: ";
                break;

            case Graph.GraphType.FunctionGraph:
                graph           = logResult.functionList.BuildFunctionGraph(new FilterForm());
                graph.graphType = Graph.GraphType.FunctionGraph;
                title           = "Function Graph for: ";
                break;

            case Graph.GraphType.ModuleGraph:
                graph           = logResult.functionList.BuildModuleGraph(new FilterForm());
                graph.graphType = Graph.GraphType.ModuleGraph;
                title           = "Module Graph for: ";
                break;

            case Graph.GraphType.ClassGraph:
                graph           = logResult.functionList.BuildClassGraph(new FilterForm());
                graph.graphType = Graph.GraphType.ClassGraph;
                title           = "Class Graph for: ";
                break;

            default:
                Debug.Assert(false);
                break;
            }
            title += fileName;
            GraphViewForm graphViewForm = new GraphViewForm(graph, title);

            graphViewForm.Visible = true;
        }
Beispiel #18
0
 private void heapGraphButton_Click(object sender, System.EventArgs e)
 {
     Graph graph = logResult.objectGraph.BuildTypeGraph(new FilterForm());
     string title = "Heap Graph for " + scenario;
     GraphViewForm graphViewForm = new GraphViewForm(graph, title);
     graphViewForm.Show();
 }
Beispiel #19
0
 private void allocationGraphButton_Click(object sender, System.EventArgs e)
 {
     Graph graph = logResult.allocatedHistogram.BuildAllocationGraph(new FilterForm());
     graph.graphType = Graph.GraphType.AllocationGraph;
     string title = "Allocation Graph for: " + scenario;
     GraphViewForm graphViewForm = new GraphViewForm(graph, title);
     graphViewForm.Show();
 }
Beispiel #20
0
 private void CreateHandleAllocationGraph(Histogram histogram, string title)
 {
     Graph graph = histogram.BuildHandleAllocationGraph(new FilterForm());
     graph.graphType = Graph.GraphType.HandleAllocationGraph;
     GraphViewForm graphViewForm = new GraphViewForm(graph, title);
     graphViewForm.Show();        
 }
        private void showHeapGraphMenuItem_Click(object sender, System.EventArgs e)
        {
            int endTickIndex = lastTickIndex;
            if (selectedEndTickIndex != 0)
            {
                endTickIndex = selectedEndTickIndex;
            }
            ReadNewLog log = sampleObjectTable.readNewLog;
            long endPos = log.TickIndexToPos(endTickIndex);

            // Read the selected portion of the log again
            ReadLogResult readLogResult = new ReadLogResult();
            readLogResult.liveObjectTable = new LiveObjectTable(log);
            readLogResult.objectGraph = new ObjectGraph(log, 0);
            log.ReadFile(0, endPos, readLogResult);
            Graph graph = readLogResult.objectGraph.BuildTypeGraph(new FilterForm());
            string title = string.Format("Heap Graph at {0:f3} seconds", lastLog.TickIndexToTime(readLogResult.objectGraph.tickIndex));
            GraphViewForm graphViewForm = new GraphViewForm(graph, title);
            graphViewForm.Visible = true;
        }