Nahum
Nahum

Reputation: 7197

corrupted performance counters?

Performance counters are EVIL. Don't use them.

if(PerformanceCounterCategory.Exists("ILoveYou")  ) // is true
{
    PerformanceCounterCategory.Delete("ILoveYou"); 
    //throws exception The **configuration registry** key is invalid
}

at System.Diagnostics.PerformanceCounterLib.RegisterFiles(String arg0, Boolean unregister)
at System.Diagnostics.PerformanceCounterLib.UnregisterCategory(String categoryName)
at System.Diagnostics.PerformanceCounterCategory.Delete(String categoryName)
at WindowsFormsApplication1.Program.SetupCategory()

All I found is this: http://blogs.msdn.com/b/oanapl/archive/2009/04/24/fix-corrupted-performance-counters.aspx (Using LODCTR /R)

and it doesn't help. As I have no idea what file are they talking about. Anyone got any other ideas?

PS I use Windows XP SP3 may this be the problem? I understand it is suppose to support performance counters fully unless I cancel the page file.

to make this clear my problemis that I'm unable to UNINSTALL my counters.

Upvotes: 12

Views: 11696

Answers (4)

Johannes S.
Johannes S.

Reputation: 4626

For me,

it was sufficient to re-create all performance counters with

lodctr /R

from a command-line with administrative rights (according to this, but skipping the manual recreation of the base performance counters)

When checking the list of performance counters in the registry in

 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009

it turned out that the content of that key startet with lots of whitespace. There was a list of performance counters with high counter indices at the very end of that key. After calling the command above, the key correctly contained the base performance counters as well (and did not contain the leading whitespace any more).

Upvotes: 3

b_levitt
b_levitt

Reputation: 7445

If you have a similar machine you can run lodctr /S:mycounters.ini to export all counters to 'mycounters.ini' and then import them on a broken machine with lodctr /R:mycounters.ini. Keep in mind though, I've only used this procedure on two machines that I knew were almost identical in terms of perf counters. I do not know if there would be issues with machines that do not match.

Upvotes: 3

CEPA
CEPA

Reputation: 2602

My company runs into problems with the performance counters getting corrupt regularly. If it is a problem with the actual counters being corrupt, you can check for corrupted Performance Counters by:

  1. Going to start | run | perfmon
  2. Click OK
  3. Click on the add button on the toolbar in the right panel ("+" sign button)
  4. Ensure that the proformance object drop down menu contains items and not just numbers
If the Counters are numbers or Blank:
  • Locate and Rename these 3 files in %windir%\system32:
    • Perfc009.dat
    • Perfh009.dat
    • Perfi009.dat
  • Insert the Windows XP Install CD
  • Browse to their CD drive and into the I386 Folder (i.e. D:\I386)
  • Locate those same files here
  • Copy and Paste them from the CD back into System32
  • Reboot the computer.
  • This is the best solution we have found for the issue.

    Upvotes: 4

    Alois Kraus
    Alois Kraus

    Reputation: 13545

    Performance counters favor speed over usability and correctness. The performance counters in XP and later Windows versions can easily be broken. It is e.g. a very bad practice to create a new performance counter category on startup of your app and delete it on shutdown. Constant change to the performance counter categories is a sure receipe of getting corrupt performance counters.

    I would create the categories only when it does not yet exist and leave it there until your app is uninstalled. Under what circumtances do you want to delete a performance counter category? The basic answer I can give to you is to not delete performance counter categories unless you need to.

    A good link how to recreate performance counters via lodctr or EXCTRLST is from RedGate. You can download it here.

    Edit1

    First you need to find a tool that does fix your issue. Exctrlst gives you a UI to re enable corrupt preformance counters.

    If that does work you can now check with procmon which registry keys are written during the repair operation and use this as input for your autorepair feature.

    Upvotes: 1

    Related Questions