3

I've been trying to find out this value out for hours now and to no avail. It's beginning to become quite frustrating.

I see this "% time spent in GC" mentioned everywhere (like https://msdn.microsoft.com/en-us/magazine/cc163528.aspx for example) but with no mention on how to retrieve it!

I've tried Visual Studio's memory profiler, ANTS (trial expired now), CLR Profiler, and PerfView. Where is this value stored so that I may read it?

John Smith
  • 8,567
  • 13
  • 51
  • 74

1 Answers1

5

It's in Performance Monitor (perfmon.exe)

  1. Start perfmon and select the process you want to monitor.
  2. Click on the big green "+" sign to add a performance counter.
  3. In the "Add Counters" dialog, select ".NET CLR Memory"
  4. Expand the counters under ".NET CLR Memory"
  5. Scroll down and select "% Time in GC"
Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • I don't see ".NET CLR Memory". Here's a screenshot: http://i.imgur.com/p2SYwKM.png – John Smith Mar 29 '15 at 04:57
  • Also, how would it know it's from this one application and not system-wide? – John Smith Mar 29 '15 at 05:00
  • @JohnSmith: Odd. My Windows 8.1 shows ".NET CLR Memory". I have an old screen shot from Windows XP that also shows ".NET CLR Memory." See https://www.informit.com/guides/content.aspx?g=dotnet&seqNum=245. I don't know why it's not showing up in whatever version of Windows you're using. – Jim Mischel Mar 29 '15 at 05:23
  • @JohnSmith: When you select the counter you're interested, the lower listbox (Instances of selected object:) will show the applications. You can select All instances or the individual processes you're interested in. – Jim Mischel Mar 29 '15 at 05:24
  • @JohnSmith: Also see http://stackoverflow.com/questions/1540777/performancecounters-on-net-4-0-windows-7, which might be related. – Jim Mischel Mar 29 '15 at 05:26
  • I tried rebuilding the counters and it said it worked but it's still not there. – John Smith Mar 29 '15 at 05:31