5

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.

JRomeo
  • 543
  • 1
  • 4
  • 20

1 Answers1

4

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>
Community
  • 1
  • 1
Leigh
  • 28,765
  • 10
  • 55
  • 103
  • 1
    "I was not familiar with it, but did a bit of searching". @Leigh, have you found some mystical way of *searching for the answers to questions*? Is it an internet thing? Enquiring minds must know. – Adam Cameron Mar 02 '14 at 15:28
  • I use a special search engine: "mystic answers". (Shhh, do not tell anyone!) Seriously though, yes they probably could have found this eventually.. but in fairness it was not a typical "3-seconds-on-google" job, like some posts. A little familiarity with .net helps, and of course gearing searches towards .net specifically had an impact (my initial searches turned up nothing). Since it was not a sixty second job for me, and I was curious too, I gave it a pass and posted a starting point that could be extended for other values like "Commit Memory", with a little research of the MS docs. – Leigh Mar 02 '14 at 16:38