When the debugger is attached to an application that repeatedly creates and joins with short-lived threads, performance monitor shows the handles associated with the application growing linearly. The growth was observed when run with the debugger in Visual Studio Code, Visual Studio and JetBrains Rider.
When the same application is run via "dotnet run" from a terminal, the handle count is stable.
Reproduction Steps
while (true)
{
var thread = new Thread(() => Thread.Sleep(1_000));
thread.Start();
thread.Join();
GC.Collect();
GC.WaitForPendingFinalizers();
Console.WriteLine($"{DateTime.Now} iterate");
}
Expected behavior
It is expected that performance monitor would show the handle count as stable like it shows when run via "dotnet run". Below is a screenshot of what performance monitor shows when running the application under "dotnet run".
Actual behavior
Below is a screenshot of what performance monitor shows when run with the debugger in Visual Studio Code. The same growth is observed when run with the debugger attached in Visual Studio and JetBrains Rider.
Regression?
The application running under the debugger shows the growth in the handles in .NET 8 and .NET Framework 4.8.
Known Workarounds
No response
Configuration
.NET 8 and .NET Framework 4.8
Windows 11
x64
Other information
When the application is run under WinDbg, it does not show growth in the handles. So possibly it is in the managed debugging code.
Description
When the debugger is attached to an application that repeatedly creates and joins with short-lived threads, performance monitor shows the handles associated with the application growing linearly. The growth was observed when run with the debugger in Visual Studio Code, Visual Studio and JetBrains Rider.
When the same application is run via "dotnet run" from a terminal, the handle count is stable.
Reproduction Steps
Expected behavior
It is expected that performance monitor would show the handle count as stable like it shows when run via "dotnet run". Below is a screenshot of what performance monitor shows when running the application under "dotnet run".
Actual behavior
Below is a screenshot of what performance monitor shows when run with the debugger in Visual Studio Code. The same growth is observed when run with the debugger attached in Visual Studio and JetBrains Rider.
Regression?
The application running under the debugger shows the growth in the handles in .NET 8 and .NET Framework 4.8.
Known Workarounds
No response
Configuration
.NET 8 and .NET Framework 4.8 Windows 11 x64
Other information
When the application is run under WinDbg, it does not show growth in the handles. So possibly it is in the managed debugging code.