void Clr_GCAllocationTick(GCAllocationTickTraceData ev) { if (_context.IsTestEvent(ev)) { _bytes += ev.AllocationAmount64; } }
private void CheckForNewProcessForTick(GCAllocationTickTraceData data) { if (UseOnlyAllocTicks) { CheckForNewProcess(data); } }
private void OnEtwGCAllocationTick(GCAllocationTickTraceData data) { if (data.ProcessID != m_processID) { return; } // Check to see if we have cached type info. var typeName = data.TypeName; if (!m_classNamesAsFrames.ContainsKey(data.TypeID)) { if (string.IsNullOrEmpty(typeName)) { // This could be project N, try to resolve it that way. TraceLoadedModule module = m_process.LoadedModules.GetModuleContainingAddress(data.TypeID, data.TimeStampRelativeMSec); if (module != null) { // Resolve the type name using project N resolution typeName = m_typeNameSymbolResolver.ResolveTypeName((int)(data.TypeID - module.ModuleFile.ImageBase), module.ModuleFile, TypeNameSymbolResolver.TypeNameOptions.StripModuleName); } } // Add the ID -> Type Name to the mapping. if (!string.IsNullOrEmpty(typeName)) { TypeInfo typeInfo = new TypeInfo() { TypeName = typeName, FrameIdx = m_stackSource.Interner.FrameIntern("Type " + typeName) }; m_classNamesAsFrames[data.TypeID] = typeInfo; } } // Support for old versions of this event long alloc = data.AllocationAmount64; if (alloc == 0) { alloc = data.AllocationAmount; if (alloc == 0) { alloc = 100000; } } // The representative size needs to be >= 85K for large objects and < 85 K for small to properly simulate the generation // where the object is allocated. We arbitrarily pick 100 for the representative size for small objects. long reprsentativeSize = alloc; if (data.AllocationKind == GCAllocationKind.Small) { reprsentativeSize = 100; } OnObjectAllocated(data, data.Address, data.TypeID, alloc, reprsentativeSize); }
private void OnGCAllocationTick(GCAllocationTickTraceData data) { TraceThread thread = data.Thread(); Debug.Assert(thread != null); if (null == thread) { return; } // Attempt to charge the allocation to a request. ScenarioThreadState scenarioThreadState = m_Configuration.ScenarioThreadState[(int)thread.ThreadIndex]; CallStackIndex traceLogCallStackIndex = data.CallStackIndex(); StackSourceCallStackIndex callStackIndex = scenarioThreadState.GetCallStackIndex(m_OutputStackSource, thread, data); // Add the thread. StackSourceFrameIndex threadFrameIndex = m_OutputStackSource.Interner.FrameIntern(thread.VerboseThreadName); callStackIndex = m_OutputStackSource.Interner.CallStackIntern(threadFrameIndex, callStackIndex); // Get the allocation call stack index. callStackIndex = m_OutputStackSource.GetCallStack(traceLogCallStackIndex, callStackIndex, null); // Add the type. string typeName = data.TypeName; if (typeName.Length > 0) { StackSourceFrameIndex nodeIndex = m_OutputStackSource.Interner.FrameIntern("Type " + data.TypeName); callStackIndex = m_OutputStackSource.Interner.CallStackIntern(nodeIndex, callStackIndex); } // Add a notification for large objects. if (data.AllocationKind == GCAllocationKind.Large) { StackSourceFrameIndex nodeIndex = m_OutputStackSource.Interner.FrameIntern("LargeObject"); callStackIndex = m_OutputStackSource.Interner.CallStackIntern(nodeIndex, callStackIndex); } // Set the time. m_Sample.TimeRelativeMSec = data.TimeStampRelativeMSec; // Set the metric. bool seenBadAllocTick = false; m_Sample.Metric = data.GetAllocAmount(ref seenBadAllocTick); // Set the stack index. m_Sample.StackIndex = callStackIndex; // Add the sample. m_OutputStackSource.AddSample(m_Sample); }
private void OnAllocationTick(GCAllocationTickTraceData data) { if (FilterOutEvent(data)) { return; } if (_verbose) { Console.WriteLine($"{data.AllocationKind,7} | {data.AllocationAmount64,10} : {data.TypeName}"); } _allocations.AddAllocation(data.AllocationKind, (ulong)data.AllocationAmount64, data.TypeName); }
private void NotifyAllocationTick(GCAllocationTickTraceData info) { var listeners = AllocationTick; listeners?.Invoke(this, new AllocationTickArgs( info.TimeStamp, info.ProcessID, info.AllocationAmount, info.AllocationAmount64, info.AllocationKind == GCAllocationKind.Large, info.TypeName, info.HeapIndex, info.Address )); }
private void OnAllocationTick(GCAllocationTickTraceData data) { if (FilterOutEvent(data)) { return; } if (_verbose) { Console.WriteLine($"{data.AllocationKind,7} | {data.AllocationAmount64,10} : {data.TypeName}"); var callstack = data.CallStack(); if (callstack != null) { DumpStack(callstack); } } _allocations.AddAllocation(data.AllocationKind, (ulong)data.AllocationAmount64, data.TypeName); }
public void AllocationTick(GCAllocationTickTraceData data, bool large, double value) { AllocTick key = new AllocTick(); // May not have type name prior to 4.5 if (!String.IsNullOrEmpty(data.TypeName)) { key.m_type = data.TypeName; } TraceCallStack stack = data.CallStack(); // Walk the call stack to find module above clr while ((stack != null) && (stack.Caller != null) && stack.CodeAddress.ModuleName.IsClr()) { stack = stack.Caller; } if (stack != null) { key.m_caller1 = stack.CodeAddress.CodeAddressIndex; stack = stack.Caller; // Walk call stack to find module above mscorlib while ((stack != null) && (stack.Caller != null) && stack.CodeAddress.ModuleName.IsMscorlib()) { stack = stack.Caller; } if (stack != null) { key.m_caller2 = stack.CodeAddress.CodeAddressIndex; } } AddAlloc(key, large, value); }
internal void OnClrEvent(TraceEvent data) { TraceEventID eventID = data.ID; HeapEvents heapEvent = HeapEvents.Unknown; // TODO don't use IDs but use individual callbacks. const TraceEventID GCStartEventID = (TraceEventID)1; const TraceEventID GCStopEventID = (TraceEventID)2; const TraceEventID GCRestartEEStopEventID = (TraceEventID)3; const TraceEventID GCHeapStatsEventID = (TraceEventID)4; const TraceEventID GCCreateSegmentEventID = (TraceEventID)5; const TraceEventID GCFreeSegmentEventID = (TraceEventID)6; const TraceEventID GCRestartEEStartEventID = (TraceEventID)7; const TraceEventID GCSuspendEEStopEventID = (TraceEventID)8; const TraceEventID GCSuspendEEStartEventID = (TraceEventID)9; const TraceEventID GCAllocationTickEventID = (TraceEventID)10; const TraceEventID GCCreateConcurrentThreadEventID = (TraceEventID)11; const TraceEventID GCTerminateConcurrentThreadEventID = (TraceEventID)12; const TraceEventID GCFinalizersStopEventID = (TraceEventID)13; const TraceEventID GCFinalizersStartEventID = (TraceEventID)14; const TraceEventID ContentionStartEventID = (TraceEventID)81; const TraceEventID ContentionStopEventID = (TraceEventID)91; switch (eventID) { case GCStartEventID: { var mdata = data as Microsoft.Diagnostics.Tracing.Parsers.Clr.GCStartTraceData; if (mdata != null) { GcEventExtra extra = GetGcEventExtra(mdata.Count); extra.GCStartIndex = data.EventIndex; extra.GCStartThread = data.Thread(); } } heapEvent = HeapEvents.GCStart; break; case GCStopEventID: heapEvent = HeapEvents.GCEnd; break; case GCRestartEEStartEventID: heapEvent = HeapEvents.GCRestartEEBegin; break; case GCRestartEEStopEventID: heapEvent = HeapEvents.GCRestartEEEnd; break; case GCHeapStatsEventID: heapEvent = HeapEvents.GCHeapStats; break; case GCCreateSegmentEventID: heapEvent = HeapEvents.GCCreateSegment; break; case GCFreeSegmentEventID: heapEvent = HeapEvents.GCFreeSegment; break; case GCSuspendEEStartEventID: heapEvent = HeapEvents.GCSuspendEEBegin; break; case GCSuspendEEStopEventID: heapEvent = HeapEvents.GCSuspendEEEnd; break; case GCAllocationTickEventID: heapEvent = HeapEvents.GCAllocationTick; { GCAllocationTickTraceData mdata = data as GCAllocationTickTraceData; AllocationTick(mdata, mdata.AllocationKind == GCAllocationKind.Large, mdata.GetAllocAmount(ref seenBadAlloc) / OneMBD); } break; case GCCreateConcurrentThreadEventID: heapEvent = HeapEvents.GCCreateConcurrentThread; break; case GCTerminateConcurrentThreadEventID: heapEvent = HeapEvents.GCTerminateConcurrentThread; break; case GCFinalizersStartEventID: heapEvent = HeapEvents.GCFinalizersBegin; break; case GCFinalizersStopEventID: heapEvent = HeapEvents.GCFinalizersEnd; break; case ContentionStartEventID: heapEvent = HeapEvents.ContentionStart; break; case ContentionStopEventID: heapEvent = HeapEvents.ContentionStop; break; default: break; } if (heapEvent != HeapEvents.Unknown) { ThreadMemoryInfo thread = GetThread(data.ThreadID); thread.AddEvent(heapEvent, data.TimeStampRelativeMSec); } }
private void OnGCAllocationTick(GCAllocationTickTraceData data) { NotifyAllocationTick(data); }
private void Clr_GCAllocationTick(GCAllocationTickTraceData ev) { if (_context.IsTestEvent(ev)) _bytes += ev.AllocationAmount64; }
private void ClrOnGcAllocationTick(GCAllocationTickTraceData data) { Console.WriteLine($"{data.AllocationKind.ToString()} : {data.TypeName} ({data.AllocationAmount})"); }