I’m writing a library plugin for an application. The plugin is written in C# using .NET Framework 4.7.1. In order to debug the application, I have to start an external program. Essentially, it’s the same mechanism as “Attach to process”. This may be relevant later.
I’m attempting to profile the CPU usage between two breakpoints using Visual Studio’s CPU Usage/Profiler diagnostic tool. When attempting to start the profiler, I get the following message.
Cannot enable CPU profiling. ETW resources have been exhausted. Try shutting down other diagnostic tools (e.g. Sysinternals) or restarting to free these resources
I have tried restarting Visual Studio with no effect. Additionally, I do not have any other diagnostic tools running that I’m aware of, aside from sysmon. I found a ‘solution’ on Microsoft’s site Troubleshoot profiling errors, which led me to execute the following command to add additional ETW loggers.
reg add “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\WMI” /v EtwMaxLoggers /t REG_DWORD /d 128
This increases the number of loggers to 128. This had no effect on the profiling error. I then attempted to further increase it to the maximum of 256 with no change in behavior. I find it hard to believe that sysmon would be using 256 ETW loggers.
I believe I can use xperf to diagnose the issue but I have no idea what I’m looking at or how to tell how many ETW loggers are in use and by what process.
Has anyone experienced this issue and have a solution or answer as to why it’s happening?