c# - Reading w3wp .Net Performance Counter Instances programmatically -


when viewing .net performance counters using performance tool can see web process performance counters listed (w3wp, w3wp#1):

performance monitor showing w3wp instances

however when run following code administrator:

var instancenames = new performancecountercategory(".net clr memory")                      .getinstancenames()                      .orderby(x => x);  foreach (var name in instancenames) {     console.writeline(name); } 

this output see:

missing w3wp instances

notice w3wp counters not listed. know why case , how can fix it?

the solution have run application in same bitness website. website 64 bit needed run console application in 64 bit mode. right click on console application project, click properties in build tab untick box says "prefer 32-bit".

also when collect process id w3wp process using process id counter inside .net clr memory category 0 begin with. process id have initialize web site , make sure @ least 1 garbage collection happens. in test code call gc.collect in application_start handler.


Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -