c# - PerformanceCounter - Custom counters file view is out of memory -


while doing load testing on our .net win32 application, ran exception:

system.typeinitializationexception: type initializer 'myclass' threw exception. ---> system.invalidoperationexception: custom counters file view out of memory.    @ system.diagnostics.sharedperformancecounter.calculatememory(int32 oldoffset, int32 totalsize, int32& alignmentadjustment)    @ system.diagnostics.sharedperformancecounter.createinstance(categoryentry* categorypointer, int32 instancenamehashcode, string instancename, performancecounterinstancelifetime lifetime)    @ system.diagnostics.sharedperformancecounter.getcounter(string countername, string instancename, boolean enablereuse, performancecounterinstancelifetime lifetime)    @ system.diagnostics.sharedperformancecounter..ctor(string catname, string countername, string instancename, performancecounterinstancelifetime lifetime)    @ system.diagnostics.performancecounter.initializeimpl()    @ system.diagnostics.performancecounter..ctor(string categoryname, string countername, string instancename, boolean readonly) 

it happens when running line:

new performancecounter("categoryname", "countername", "instancename", false); 

i'm not familiar performance counter, seeing message, understand stored in file, responsability of developer clear file? if yes how? if no, should do?

i've 5 instance of application running on same machine.

performance counters implement idisposable, can use

directly:

 perfcounter.close();  perfcounter.dispose(); 

indirectly:

using(performancecounter perfcounter=new performancecounter()) {    //your code. } 

to clear resources.

also can allocate more memory performance counter using registry. see post in documentation: https://msdn.microsoft.com/en-us/library/system.diagnostics.performancecounter(v=vs.110).aspx

performance counter categories installed .net framework 2.0 use separate shared memory, each performance counter category having own memory. can specify size of separate shared memory creating dword named filemappingsize in registry key hkey_local_machine\system\currentcontrolset\services\\performance. filemappingsize value set shared memory size of category. default size 131072 decimal. if filemappingsize value not present, filemappingsize attribute value performancecounters element specified in machine.config file used, causing additional overhead configuration file processing. can realize performance improvement application startup setting file mapping size in registry. more information file mapping size, see element.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -