Beispiel #1
0
        /// <summary>
        /// Execute the pinned object analyzer.
        /// </summary>
        internal void Execute(
            GCPinnedObjectViewType viewType)
        {
            // Process the heap snapshot, and populate the root table and process id.
            ProcessHeapSnapshot();

            // Instantiate the necessary trace event parsers.
            TraceEventDispatcher     eventDispatcher = _TraceLog.Events.GetSource();
            PerfViewTraceEventParser perfViewParser  = new PerfViewTraceEventParser(eventDispatcher);

            // we want the state of the heap at the time the snapshot was taken.
            perfViewParser.TriggerHeapSnapshot += delegate(TriggerHeapSnapshotTraceData data)
            {
                eventDispatcher.StopProcessing();
            };

            var heapWithPinningInfo = new PinningStackAnalysis(eventDispatcher, _TraceLog.Processes.GetProcess(_ProcessID, _TraceLog.SessionDuration.TotalMilliseconds), _StackSource, _Log);

            // Process the ETL file up until we detect that the heap snapshot was taken.
            eventDispatcher.Process();

            // Iterate through all pinned objects in the heap snapshot.
            foreach (KeyValuePair <Address, PinningRoot> pinnedPair in _RootTable)
            {
                // Try to match the object in the heap snapshot with an object in the ETL.
                PinningStackAnalysisObject liveObjectInfo = heapWithPinningInfo.GetPinningInfo(pinnedPair.Key);
                if (liveObjectInfo != null)
                {
                    // Found a match, write the appropriate call stacks.
                    if (viewType == GCPinnedObjectViewType.PinnedObjectAllocations)
                    {
                        WriteAllocationStack(pinnedPair.Key, pinnedPair.Value, liveObjectInfo);
                    }
                    else if (viewType == GCPinnedObjectViewType.PinnedHandles)
                    {
                        WritePinningStacks(pinnedPair.Key, pinnedPair.Value, liveObjectInfo);
                    }
                }
            }
        }
Beispiel #2
0
        public QuadrantTestContext(TraceEventDispatcher source)
            : base(source)
        {
            source.Dynamic.AddCallbackForProviderEvent(
                QuadrantPerformanceTestAttribute.QuadrantProvider,
                "AppSuspended",
                e =>
            {
                source.StopProcessing();
                _closeSemaphore.Release();
            });

            source.Dynamic.AddCallbackForProviderEvent(
                PerformanceTestAttribute.XamlProviderName,
                "ElementCreated",
                e => _elementCreationTimes.Add(e.TimeStampRelativeMSec));

            source.Dynamic.AddCallbackForProviderEvent(
                PerformanceTestAttribute.XamlProviderName,
                "ResourceDictionaryAdd",
                e => _resourceDictionaryAddTimes.Add(e.TimeStampRelativeMSec));
        }
Beispiel #3
0
    internal void SetupCallbacks(MemoryGraph memoryGraph, TraceEventDispatcher source, int processID = 0, double startTimeRelativeMSec = 0)
    {
        m_graph           = memoryGraph;
        m_types           = new Dictionary <string, NodeTypeIndex>(10000);
        m_nodeBlocks      = new Queue <BulkNodeTraceData>();
        m_attributeBlocks = new Queue <BulkAttributeTraceData>();
        m_edgeBlocks      = new Queue <BulkEdgeTraceData>();
        m_ignoreEvents    = true;
        m_ignoreUntilMSec = startTimeRelativeMSec;
        m_processId       = processID;

        var jsDump = new JSDumpHeapTraceEventParser(source);

        jsDump.JSDumpHeapEnvelopeStart += delegate(SettingsTraceData data)
        {
            if (data.TimeStampRelativeMSec < m_ignoreUntilMSec)
            {
                return;
            }
            if (m_processId == 0)
            {
                m_processId = data.ProcessID;
            }
            if (data.ProcessID != m_processId)
            {
                return;
            }

            if (!m_seenStart)
            {
                m_ignoreEvents = false;
            }
            m_seenStart = true;
        };
        jsDump.JSDumpHeapEnvelopeStop += delegate(SummaryTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            m_ignoreEvents = true;
            source.StopProcessing();
        };
        jsDump.JSDumpHeapBulkNode += delegate(BulkNodeTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            m_nodeBlocks.Enqueue((BulkNodeTraceData)data.Clone());
        };
        jsDump.JSDumpHeapBulkAttribute += delegate(BulkAttributeTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            m_attributeBlocks.Enqueue((BulkAttributeTraceData)data.Clone());
        };
        jsDump.JSDumpHeapBulkEdge += delegate(BulkEdgeTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            m_edgeBlocks.Enqueue((BulkEdgeTraceData)data.Clone());
        };
        jsDump.JSDumpHeapStringTable += delegate(StringTableTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            for (int i = 0; i < data.Count; i++)
            {
                m_stringTable.Add(data.Strings(i));
            }
        };
        jsDump.JSDumpHeapDoubleTable += delegate(DoubleTableTraceData data)
        {
            if (m_ignoreEvents || data.ProcessID != m_processId)
            {
                return;
            }
            for (int i = 0; i < data.Count; i++)
            {
                m_doubleTable.Add(data.Doubles(i));
            }
        };
    }