Copy link to clipboard
Copied
How to check for available system memory on Coldfusion server and also when I use local host?
Copy link to clipboard
Copied
A user-level process cannot reliably query "system memory," and even if it did, it's not going to get a true and useful accounting. There are a several conceptual reasons why this is so:
There's also something to be said for "the Greyhound Principle," viz: "Leave the driving to us." Application programs are supposed to just be "along for the ride." It's really none of their concern how busy or how crowded the system(s) as a whole might be. Their only concern should be that they must fairly state to the system how many resources they individually need, and to make good and efficient use of the resources they have been given. The application's design should be such that it is "a good neighbor," built with an awareness of how the operating system goes about its business but without being nosy or trying to second-guess what the system is doing. (If you try too hard to do that, you can actually create a "negative feedback loop" effect which makes your app harder for the operating system to manage properly!)
Copy link to clipboard
Copied
Can you expand on your issue overall?
Java can return how much memory it is consuming, or for the server (on windows) you could use perfmon to log the memory usage.
If we know the end game we might be able to help further.
Byron Mann
mannb@hostmysite.com
byronosity@gmail.com
Software Architect
hosting.com | hostmysite.com
http://www.hostmysite.com/?utm_source=bb
Copy link to clipboard
Copied
You could just copy and paste the JVM memory code from Dan G Switzer's site.
Copy link to clipboard
Copied
Here is what I use:
<cfset runtime = CreateObject("java", "java.lang.Runtime").getRuntime()>
<cfset freeMemory = runtime.freeMemory() / 1024 / 1024>
<cfset totalMemory = runtime.totalMemory() / 1024 / 1024>
<cfset maxMemory = runtime.maxMemory() / 1024 / 1024>
Max Memory Available to JVM: #Round(maxMemory)# MB<br>
Total Memory Allocated: #Round(totalMemory)# MB<br>
Free Allocated Memory: #Round(freeMemory)# MB