Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can ColdFusion Access Windows Memory Values

Is there a way for ColdFusion 8/9, via Java or other means to retrieve or calculate memory metrics on the Windows OS such as jrun's Private Work Set Memory and Commit Memory values?

Note that the desired memory values are not to be confused with JVM free memory and other heap related stats available using the Java Runtime object. Thank you.

like image 286
JRomeo Avatar asked Oct 02 '22 10:10

JRomeo


1 Answers

I was not familiar with it, but did a bit of searching and found this thread which suggests it can be done with .NET System.Diagnostics. Below is a translation, which seems to work CF 9 / .NET 3.5 / Win7. It should at least give you a starting point.

<cfscript>
    process = createObject(".net", "System.Diagnostics.Process");
    PerfCounter = createObject(".net", "System.Diagnostics.PerformanceCounter")
    counter = PerfCounter.init("Process", "Working Set - Private", "jrun");
    WriteDump( (counter.get_RawValue() / 1024) &"K");
</cfscript>
like image 87
Leigh Avatar answered Oct 13 '22 10:10

Leigh