c# - How to fix OutOfMemoryException for PerformanceCounterCategory.GetInstanceName -
if execute code
performancecountercategory cat = new performancecountercategory("process"); var instances = cat.getinstancenames(); // outofmemoryexception
i outofmemoryexception
full stack trace is
a first chance exception of type 'system.outofmemoryexception' occurred in mscorlib.dll system.outofmemoryexception: exception of type "system.outofmemoryexception" occured. @ microsoft.win32.registrykey.internalgetvalue(string name, object defaultvalue, boolean donotexpand, boolean checksecurity) @ microsoft.win32.registrykey.getvalue(string name) @ system.diagnostics.performancemonitor.getdata(string item) @ system.diagnostics.performancecounterlib.getperformancedata(string item) @ system.diagnostics.performancecounterlib.get_categorytable() @ system.diagnostics.performancecounterlib.getcategorysample(string machine, string category) @ system.diagnostics.performancecountercategory.getcounterinstances(string categoryname, string machinename) @ windowsformsapplication5.form1.button1_click(object sender, eventargs e)
this happens in x64 exe if run same code under x86 works. ideas how solve this?
os windows 8.1 x64, 8gb ram (this not physical memory issue).
i solved knowlegebase article how manually rebuild performance counter library values
- backup
perfc009.dat
,perfh009.dat
in%systemroot%\system32
- copy files installation media %systemroot%\system32. while kb article server 2008 , on windows 8.1 extracted files installation dvd's file
sources\install.wim
(folder2\windows\system32\
windows 8 pro) 7-zip. - in registry, change last counter value 1846 (decimal), , change last value 1847 (decimal).
- remove following values performance subkey (if exist):
first counter, first help, last counter, last help
- use
lodctr /r
(i did admin cmd prompt once in system32 , syswow64 folder sure) reenable third party counters - the article suggests, if .net applications fail start, have reinstall .net assemblies create performance counters, e.g.
installutil /i microsoft.mom.configservice.dll
not necessary in case.
Comments
Post a Comment