Conversation
| var gcInfo = GC.GetGCMemoryInfo(); | ||
| return gcInfo.HeapSizeBytes != 0 ? gcInfo.FragmentedBytes * 100d / gcInfo.HeapSizeBytes : 0; | ||
| }) { DisplayName = "GC Fragmentation", DisplayUnits = "%" }; | ||
| _committedCounter ??= new PollingCounter("gc-committed", this, () => GC.GetGCMemoryInfo().TotalCommittedBytes) { DisplayName = "GC Committed Bytes", DisplayUnits = "B" }; |
There was a problem hiding this comment.
it seems like we could easily avoid calling GC.GetGCMemoryInfo again if we already had to call it to get the info for the counter right above...
There was a problem hiding this comment.
It's inside the lambda. Might be nice if there were some kind of facility for enabling all counters associated with the same event source to be handed the results of some shared computation, e.g. so that prior to invoking both gc-fragmentation and gc-committed, it could do a single GetGCMemoryInfo call that both would then be handed.
There was a problem hiding this comment.
Yes, this gets passed as a lambda and is executed by the CounterGroup. It would be nice to add what @stephentoub suggested so that counters within the same provider can share some state. I'll look into adding that in the future.
This adds GC committed bytes counter to
System.Runtime.