public ClrProfilerAllocStackSource(string clrProfilerFileName) { m_fileName = clrProfilerFileName; m_clrProfiler = new ClrProfilerParser(); m_gcHeap = new GCSimulation(m_clrProfiler); m_clrProfiler.ReadFile(m_fileName); }
public ClrProfilerMethodSizeStackSource(string clrProfilerFileName) { m_fileName = clrProfilerFileName; m_clrProfiler = new ClrProfilerParser(); m_calls = new GrowableArray <int>(1000000); m_clrProfiler.Call += delegate(ProfilerStackTraceID stackId, uint threadId) { m_calls.Add((int)stackId); var method = m_clrProfiler.Method(stackId); var stats = (MethodStats)method.UserData; if (stats == null) { m_totalMethodSize += (int)method.size; m_totalMethodCount++; method.UserData = stats = new MethodStats(); // Debug.WriteLine(string.Format("METHOD Size {1,6}: {0}", method.name, method.size)); } stats.count++; }; m_clrProfiler.ReadFile(m_fileName); // Debug.WriteLine(string.Format("MethodSize {0} MethodCount {1} callCount {2}", m_totalMethodSize, m_totalMethodCount, m_calls.Count)); }
public ClrProfilerMemoryGraph(string profilerFile) : base(10000) { // Needed for the callback in ReadFile m_tempChildren = new GrowableArray <NodeIndex>(1000); ClearWorker(); m_clrProfilerParser = new ClrProfilerParser(); m_clrProfilerParser.ObjectDescription += OnObjectDescription; m_clrProfilerParser.GCRoot += OnGCRoot; m_clrProfilerParser.HeapDump += OnHeapDump; m_clrProfilerParser.StaticVar += OnStaticVar; m_clrProfilerParser.LocalVar += OnLocalVar; m_clrProfilerParser.ReadFile(profilerFile); // set the module names on every type if present. var nodeTypeStorage = AllocTypeNodeStorage(); for (var profilerTypeId = 0; profilerTypeId < (int)m_clrProfilerParser.TypeIdLimit; profilerTypeId++) { var profilerType = m_clrProfilerParser.GetTypeById((ProfilerTypeID)profilerTypeId); if (profilerType == null) { continue; } var module = profilerType.Module; if (module != null && profilerTypeId < m_profilerTypeToNodeType.Count) { var nodeTypeId = m_profilerTypeToNodeType[profilerTypeId]; if (nodeTypeId != NodeTypeIndex.Invalid) { var nodeType = GetType((NodeTypeIndex)nodeTypeId, nodeTypeStorage); nodeType.ModuleName = profilerType.Module.name; } } } // Now we have module information, process the defer local and static processing foreach (var deferedRoot in m_deferedRoots) { ProfilerType profilerType = m_clrProfilerParser.GetTypeById(deferedRoot.typeID); var appDomainNode = m_rootNode.FindOrCreateChild("[appdomain " + deferedRoot.appDomainName + "]"); var varKindNode = appDomainNode.FindOrCreateChild("[" + deferedRoot.prefix + " vars]"); var moduleName = System.IO.Path.GetFileNameWithoutExtension(profilerType.ModuleName); var moduleNode = varKindNode.FindOrCreateChild("[" + deferedRoot.prefix + " vars " + moduleName + "]"); var typeNode = moduleNode.FindOrCreateChild("[" + deferedRoot.prefix + " vars " + profilerType.name + "]"); var node = typeNode.FindOrCreateChild( profilerType.name + "+" + deferedRoot.name + " [" + deferedRoot.prefix + " var]", profilerType.ModuleName); node.AddChild(deferedRoot.nodeIndex); } // finish off the root nodes. RootIndex = m_rootNode.Build(); AllowReading(); // These are only needed for the callbacks in 'ReadFile' save space by clearing them out. m_clrProfilerParser = null; m_tempChildren = new GrowableArray <NodeIndex>(); // Clear the array m_profilerTypeToNodeType = new GrowableArray <NodeTypeIndex>(); // Clear the array m_rootNode = null; m_rootNodeForUnknownRoot = null; m_addressToNodeIndex = null; m_deferedRoots = null; }