ColdFusion Memory Usage Stats
Here are some code to find out some info about the memory usage of CFMX or BlueDragon. The Java API provides three methods in the java.lang.Runtime class: freeMemory, totalMemory, and maxMemory. These methods provide information about the JVM's memory usage, and its easy to access them with CFML:
<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> <cfoutput> Free Allocated Memory: #Round(freeMemory)#mb<br> Total Memory Allocated: #Round(totalMemory)#mb<br> Max Memory Available to JVM: #Round(maxMemory)#mb<br> </cfoutput>
From these numbers we can also determine the percent of free allocated memory available, and also the percent of avalaible memory allocated
<cfset percentFreeAllocated = Round((freeMemory / totalMemory) * 100)> <cfset percentAllocated = Round((totalMemory / maxMemory ) * 100)> <cfoutput> % of Free Allocated Memory: #percentFreeAllocated#%<br> % of Available Memory Allocated: #percentAllocated#%<br> </cfoutput>
Like this? Follow me ↯Tweet Follow @pfreitag
ColdFusion Memory Usage Stats was first published on March 15, 2004.
If you like reading about jvm, cf, java, heap, monitoring, or memory then you might also like:
- Server Memory Flash Remoting Tool
- Getting Size of Heap and Non Heap Memory in CFML
- Robi Sen on Hung Servers, java.lang.OutOfMemory errors and Tuning CF JVM
- 1.8GB Heap Limit in ColdFusion MX
- ColdFusion Garbage
- Have you tuned your JVM on ColdFusion MX yet?
- Updating Java on ColdFusion or Lucee
- Adobe Says Go Ahead and Upgrade your ColdFusion JVM
The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.