On a particular Vista machine, I was setting up a PerfMon view to monitor the .NET memory performance of an application and ran into a problem. The.NET Memory # Bytes in All Heaps Performance Counter wasn’t in the list of performance counters. That was quite odd so I checked if that Performance Counter was there in Process Explorer by adding it to the main window display. Since Process Explorer has all the Performance Counter names hard coded, that would tell me if the problem was with the Performance Counter Library itself as PerfMon builds the list dynamically.

After pressing OK, Process Explorer showed no values at all in the columns. That pretty much proved that there was something seriously wrong with the Performance Counters on that particular machine. Without those performance counters it’s pretty hard to do monitoring and performance tuning! Comparing two machines side by side, I noticed that the problem machine was missing a metric ton of other Performance Counters.

A few quick internet searches got me to the Microsoft KB article 300956, which discusses how to manually rebuild Performance Counter Libraries. If you read over that article, you start to get very scared very quickly because it tells you to manually replace files on the machine with the files from the installation CD, a bunch of manual registry editing, and so on. Fortunately, at the end of the article, they mention that running LODCTR /R from an elevated prompt (note the /R uppercase is required) will rebuild the Performance Counter Library including third party and extension performance counters.

Figuring I had nothing left to lose, I gave it a run. After shutting down PerfMon and Process Explorer, I restarted both and was very happy to see all the Performance Counters reappeared. After a big sigh of relief, I thought I’d write up what worked in case you are missing some Performance Counters. Of course, this advice comes with the usual Internet warning: Worked on My Machine ™.