I have code that uses the Microsoft.Diagnostics.Tracing.TraceEvent NuGet package, and I wrote the following code:
using (var session = new TraceEventSession("mine")) { session.StopOnDispose = true; session.EnableProvider(ClrTraceEventParser.ProviderGuid, TraceEventLevel.Verbose, (ulong)ulong.MaxValue,//,ClrTraceEventParser.Keywords.GCSampledObjectAllocationHigh, new TraceEventProviderOptions { StacksEnabled = true, }); using (TraceLogEventSource traceLogSource = TraceLog.CreateFromTraceEventSession(session)) { traceLogSource.Clr.GCSampledObjectAllocation += data => { Console.WriteLine(data); }; traceLogSource.Process(); } }
This gives me an output that looks something like this:
<Event MSec="10355.9688" PID="7056" PName="" TID="11468" EventName="GC/SampledObjectAllocation" Address="0x000000C780036870" TypeID="0x00007FFF1EC60BD8" ObjectCountForTypeSample="1" TotalSizeForTypeSample="28" ClrInstanceID="9" />
What is clear enough, there is one selected object, and its size is 28 bytes. However, I do not know how to match TypeID with type name.
It seems that this would do what I want:
traceLogSource.Clr.TypeBulkType += data => { for (int i = 0; i < data.Count; i++) { var e = data.Values(i); Console.WriteLine("{0} -> {1}", e.TypeID, e.TypeName); } };
But I donโt know how to cause it to be sent from a process that I am checking (which can be very long.) The type of the array seems to be sent only when the process starts (only monitoring), and I can not find any documents for them.
Any ideas how to do this?
profiling etw
Ayende Rahien
source share