Reputation: 55
We have a WPF app (x64) running on .NET4.8 and we used to print GC/memory related stats onto log periodically using System.Diagnostics.PerformanceCounter. (Using category: ".NET CLR Memory")
After I migrated it to .NET6, counters on ".NET CLR Memory" category throws error because the instance (which is the process name) is missing.
I then check this from perfmon, and realized that our app is no longer showed in the instance list.
Since we distribute our desktop app to enduser, we record the gc stats periodically onto log while they are running the app. So using external tool adhoc is not an option to us.
I want to know for a .NET6 app:
Many thanks for your help & advice!
I have tried below things, but still the app can't be found on perfmon:
Upvotes: 1
Views: 294
Reputation: 17185
.NET 6.0 has improved built-in GC statistics that can be accessed directly on the GC
class instead of using the performance counter infrastructure. You can get a lot of information about the current process' memory usage by calling the new method GC.GetGCMemoryInfo()
.
Upvotes: 0