private static void ShowResults(PerProcessProfilingState processes, bool sortBySize, int topTypesLimit) { foreach (var pid in processes.Allocations.Keys) { ShowResults(GetProcessName(pid, processes.Names), processes.Allocations[pid], sortBySize, topTypesLimit); } }
private static void ShowResults(PerProcessProfilingState processes, bool sortBySize, int topTypesLimit) { foreach (var pid in processes.Allocations.Keys) { // skip processes without symbol resolution if (!processes.Methods.ContainsKey(pid)) { continue; } ShowResults(GetProcessName(pid, processes.Names), processes.Methods[pid], processes.Allocations[pid], sortBySize, topTypesLimit); } }
static async Task <int> Main(string[] args) { ShowHeader(); try { (bool noSampling, bool sortBySize, int topTypesLimit)parameters = GetParameters(args); TraceEventSession session = new TraceEventSession( "SampledObjectAllocationMemoryProfilingSession", TraceEventSessionOptions.Create ); using (var processes = new PerProcessProfilingState()) { var profiler = new SampledObjectAllocationMemoryProfiler(session, processes); var task = profiler.StartAsync(parameters.noSampling); Console.WriteLine("Press ENTER to stop memory profiling"); Console.ReadLine(); // this will exit the session.Process() call session.Dispose(); try { await task; ShowResults(processes, parameters.sortBySize, parameters.topTypesLimit); return(0); } catch (Exception x) { Console.WriteLine(x.Message); ShowHelp(); } } return(-1); } catch (Exception x) { Console.WriteLine(x.Message); ShowHelp(); } return(-2); }
public SampledObjectAllocationMemoryProfiler(TraceEventSession session, PerProcessProfilingState processes) { _session = session; _processes = processes; _currentPid = Process.GetCurrentProcess().Id; }