Note that there are some explanatory texts on larger screens.

plurals
  1. POC#: Accessing PerformanceCounters for the ".NET CLR Memory category"
    primarykey
    data
    text
    <p>I'm trying to access the performance counters located in <a href="http://msdn.microsoft.com/en-us/library/x2tyfybc(v=VS.100).aspx" rel="noreferrer">".NET CLR Memory category"</a> through C# using the PerformanceCounter class. However a cannot instantiate the categories with what I would expect was the correct category/counter name</p> <pre><code>new PerformanceCounter(".NET CLR Memory", "# bytes in all heaps", Process.GetCurrentProcess().ProcessName); </code></pre> <p>I tried looping through categories and counters using the following code</p> <pre><code>string[] categories = PerformanceCounterCategory.GetCategories().Select(c =&gt; c.CategoryName).OrderBy(s =&gt; s).ToArray(); string toInspect = string.Join(",\r\n", categories); System.Text.StringBuilder interestingToInspect = new System.Text.StringBuilder(); string[] interestingCategories = categories.Where(s =&gt; s.StartsWith(".NET") || s.Contains("Memory")).ToArray(); foreach (string interestingCategory in interestingCategories) { PerformanceCounterCategory cat = new PerformanceCounterCategory(interestingCategory); foreach (PerformanceCounter counter in cat.GetCounters()) { interestingToInspect.AppendLine(interestingCategory + ":" + counter.CounterName); } } toInspect = interestingToInspect.ToString(); </code></pre> <p>But could not find anything that seems to match. Is it not possible to observe these values from within the CLR or am I doing something wrong.</p> <p>The environment, should it matter, is .NET 4.0 running on a 64-bit windows 7 box.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload