Skip to content

EventListener does not project GCPerHeapHistory_V3 values array #1144

@noahfalk

Description

@noahfalk

The GCPerHeapHistory_V3 event has an array called 'Values'. This array of structs should be projected into the EventListener event model but it is absent. Most likely this is a broader issue handling array typed fields, or perhaps dynamically sized array-typed fields.

Repro:

using System;
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApp19
{
    class Program
    {
        static List<object> s_objects = new List<object>();

        static void Main(string[] args)
        {
            GCEventListener listener = new GCEventListener();
            Task.Run(AllocateMemory);
            Console.ReadLine();
        }

        static void AllocateMemory()
        {
            while (true)
            {
                s_objects.Add(new byte[50_000]);
                Thread.Sleep(10);
            }
        }
    }

    public class GCEventListener : EventListener
    {
        enum ClrRuntimeEventKeywords
        {
            GC = 0x1
        }

        protected override void OnEventSourceCreated(EventSource eventSource)
        {
            if (eventSource.Name.Equals("Microsoft-Windows-DotNETRuntime"))
            {
                EnableEvents(eventSource, EventLevel.Informational, (EventKeywords)ClrRuntimeEventKeywords.GC);
            }
        }
        protected override void OnEventWritten(EventWrittenEventArgs eventData)
        {
            if (eventData.EventName == "GCPerHeapHistory_V3")
            {
                Console.WriteLine(eventData.EventName);
                foreach (string name in eventData.PayloadNames)
                {
                    Console.WriteLine("    " + name);
                }
            }
        }
    }
}

Expected behavior: this app should print a payload field named "Values" in addition to the others
(and assuming that works you should be able to retrieve the array and access the nested fields)
Actual behavior: the app prints over payload fields, but not "Values"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions