Forum Discussion
AlexeyK
Alumni
14 years agoJim,
The counter you are looking for is available via WMI. Use the Win32_PerfFormattedData_NETFramework_NETCLRMemory class. Here is sample code:
Sub Get_NETCLRMemory_Counter
' My process name
myProcess = "_Global_" ' You can specify your executable's name here, e.g. Orders
computerName = "."
' Connect to WMI via COM
Set objWMIService = GetObject("winmgmts:\\" & computerName & "\root\cimv2")
Set PerfProcess = objWMIService.Get( _
"Win32_PerfFormattedData_NETFramework_NETCLRMemory.Name='" & myProcess & "'")
' Get the Get 2 heap size value
Log.Message "Gen 2 heap size: " & aqConvert.VarToStr(PerfProcess.Gen2heapsize)
' Output all the properties of the NETCLRMemory class
' Can be useful in the future ;-)
s = ""
For Each prop In PerfProcess.Properties_
s = s & prop.Name & ": " & aqConvert.VarToStr(prop.Value) & vbNewLine
Next
Log.Message "Properties", s ' Post to the Additional Information panel of the log
End Sub