static void PrintMethodAllocationsPerClass (TextWriter writer, LoadedClass.AllocationsPerMethod allocationsPerMethod, bool JitTime, bool printStackTraces, double stackTraceTreshold) { if (! JitTime) { writer.WriteLine (" {0} bytes ({1} instances) from {2}.{3}", allocationsPerMethod.AllocatedBytes, allocationsPerMethod.AllocatedInstances, allocationsPerMethod.Method.Class.Name, allocationsPerMethod.Method.Name); } else { writer.WriteLine (" {0} bytes ({1} instances) at JIT time in {2}.{3}", allocationsPerMethod.AllocatedBytes, allocationsPerMethod.AllocatedInstances, allocationsPerMethod.Method.Class.Name, allocationsPerMethod.Method.Name); } if (printStackTraces) { LoadedClass.AllocationsPerStackTrace [] stackTraces = allocationsPerMethod.StackTraces; Array.Sort (stackTraces, LoadedClass.AllocationsPerStackTrace.CompareByAllocatedBytes); Array.Reverse (stackTraces); double cumulativeAllocatedBytesPerStackTrace = 0; foreach (LoadedClass.AllocationsPerStackTrace trace in stackTraces) { if (cumulativeAllocatedBytesPerStackTrace / allocationsPerMethod.AllocatedBytes < stackTraceTreshold) { writer.WriteLine (" {0} bytes ({1} instances) inside", trace.AllocatedBytes, trace.AllocatedInstances); for (StackTrace frame = trace.Trace; frame != null; frame = frame.Caller) { writer.Write (" "); if (frame.MethodIsBeingJitted) { writer.Write ("[JIT time]:"); } writer.WriteLine ("{0}.{1}", frame.TopMethod.Class.Name, frame.TopMethod.Name); } } else { break; } cumulativeAllocatedBytesPerStackTrace += (double)trace.AllocatedBytes; } } }
void FilterCurrentSetByCurrentClass() { LoadedClass currentClass = (LoadedClass)Explorer.CurrentListSelection.Statistics.Subject; if (Explorer.CurrentSelection is HeapExplorerTreeModel.Node <HeapObject> ) { FilterCurrentSet <HeapObject> (new HeapItemIsOfClass <HeapObject> (currentClass)); } if (Explorer.CurrentSelection is HeapExplorerTreeModel.Node <AllocatedObject> ) { FilterCurrentSet <AllocatedObject> (new HeapItemIsOfClass <AllocatedObject> (currentClass)); } }
public void OnFilterByIsReferencedByObjectOfClass() { HeapExplorerTreeModel.Node <HeapObject> node = CurrentSelection as HeapExplorerTreeModel.Node <HeapObject>; if (node != null) { LoadedClass c = LoadedClassChooser.ChooseClass(node.Root.Items.ClassStatistics); if (c != null) { IHeapObjectFilter filter = new HeapObjectIsReferencedByObjectOfClass(c); node.Filter(filter); } } }
public void OnFilterByClass <HI> () where HI : IHeapItem { HeapExplorerTreeModel.Node <HI> node = CurrentSelection as HeapExplorerTreeModel.Node <HI>; if (node != null) { LoadedClass c = LoadedClassChooser.ChooseClass(CurrentSelection.Items.ClassStatistics); if (c != null) { HeapItemIsOfClass <HI> filter = new HeapItemIsOfClass <HI> (c); node.Filter(filter); } } }
static void PrintClassAllocationData (TextWriter writer, ProfilerEventHandler data, LoadedClass c, ulong totalAllocatedBytes) { double allocatedBytesPerClass = (double)c.AllocatedBytes; writer.WriteLine ("{0,5:F2}% ({1} bytes) {2}", ((allocatedBytesPerClass / totalAllocatedBytes) * 100), c.AllocatedBytes, c.Name); if (data.Directives.AllocationsHaveStackTrace) { LoadedClass.AllocationsPerMethod[] allocationsPerMethodArray = c.Methods; double cumulativeAllocatedBytesPerMethod = 0; if (c.MethodsAtJitTimeCount > 0) { LoadedClass.AllocationsPerMethod[] allocationsPerMethodAtJitTime = c.MethodsAtJitTime; LoadedClass.AllocationsPerMethod[] totalAllocationsPerMethod = new LoadedClass.AllocationsPerMethod [allocationsPerMethodArray.Length + allocationsPerMethodAtJitTime.Length]; Array.Copy (allocationsPerMethodArray, totalAllocationsPerMethod, allocationsPerMethodArray.Length); Array.Copy (allocationsPerMethodAtJitTime, 0, totalAllocationsPerMethod, allocationsPerMethodArray.Length, allocationsPerMethodAtJitTime.Length); allocationsPerMethodArray = totalAllocationsPerMethod; } if (allocationsPerMethodArray.Length != 0) { Array.Sort (allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse (allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass (writer, allocationsPerMethod, false, cumulativeAllocatedBytesPerMethod < allocatedBytesPerClass * 0.7, 0.7); cumulativeAllocatedBytesPerMethod += (double)allocationsPerMethod.AllocatedBytes; } } } else { LoadedClass.AllocationsPerMethod[] allocationsPerMethodArray = c.Methods; if (allocationsPerMethodArray.Length != 0) { Array.Sort (allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse (allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass (writer, allocationsPerMethod, false, false, 0); } } if (c.MethodsAtJitTimeCount > 0) { allocationsPerMethodArray = c.MethodsAtJitTime; Array.Sort (allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse (allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass (writer, allocationsPerMethod, true, false, 0); } } } }
public MethodNode (ProfileStore store, Node parent, LoadedClass.AllocationsPerMethod instance) : base (store, parent) { this.instance = instance; }
public ClassNode (ProfileStore store, Node parent, LoadedClass instance) : base (store, parent) { this.instance = instance; }
static void PrintClassAllocationData(TextWriter writer, ProfilerEventHandler data, LoadedClass c, ulong totalAllocatedBytes) { double allocatedBytesPerClass = (double)c.AllocatedBytes; writer.WriteLine("{0,5:F2}% ({1} bytes) {2}", ((allocatedBytesPerClass / totalAllocatedBytes) * 100), c.AllocatedBytes, c.Name); if (data.Directives.AllocationsHaveStackTrace) { LoadedClass.AllocationsPerMethod[] allocationsPerMethodArray = c.Methods; double cumulativeAllocatedBytesPerMethod = 0; if (c.MethodsAtJitTimeCount > 0) { LoadedClass.AllocationsPerMethod[] allocationsPerMethodAtJitTime = c.MethodsAtJitTime; LoadedClass.AllocationsPerMethod[] totalAllocationsPerMethod = new LoadedClass.AllocationsPerMethod [allocationsPerMethodArray.Length + allocationsPerMethodAtJitTime.Length]; Array.Copy(allocationsPerMethodArray, totalAllocationsPerMethod, allocationsPerMethodArray.Length); Array.Copy(allocationsPerMethodAtJitTime, 0, totalAllocationsPerMethod, allocationsPerMethodArray.Length, allocationsPerMethodAtJitTime.Length); allocationsPerMethodArray = totalAllocationsPerMethod; } if (allocationsPerMethodArray.Length != 0) { Array.Sort(allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse(allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass(writer, allocationsPerMethod, false, cumulativeAllocatedBytesPerMethod < allocatedBytesPerClass * 0.7, 0.7); cumulativeAllocatedBytesPerMethod += (double)allocationsPerMethod.AllocatedBytes; } } } else { LoadedClass.AllocationsPerMethod[] allocationsPerMethodArray = c.Methods; if (allocationsPerMethodArray.Length != 0) { Array.Sort(allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse(allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass(writer, allocationsPerMethod, false, false, 0); } } if (c.MethodsAtJitTimeCount > 0) { allocationsPerMethodArray = c.MethodsAtJitTime; Array.Sort(allocationsPerMethodArray, LoadedClass.AllocationsPerMethod.CompareByAllocatedBytes); Array.Reverse(allocationsPerMethodArray); foreach (LoadedClass.AllocationsPerMethod allocationsPerMethod in allocationsPerMethodArray) { PrintMethodAllocationsPerClass(writer, allocationsPerMethod, true, false, 0); } } } }
public ClassNode(ProfileStore store, Node parent, LoadedClass instance) : base(store, parent) { this.instance = instance; }
public override void HeapObjectUnreachable(LoadedClass c, uint size) { lastHeapSnapshot.HeapObjectUnreachable(c, size); }