Created
January 19, 2022 15:31
-
-
Save paulklinkenberg/f4b6937c5a8ed954523bbcc2e3dcdbfb to your computer and use it in GitHub Desktop.
Lucee / CFML code to display the available memory, allocated memory, and max memory in html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfoutput> | |
#getMem()# | |
</cfoutput> | |
<cfscript> | |
function getMem(){ | |
var runtime = createObject('java', 'java.lang.Runtime').getRuntime(); | |
var maxMemory = runtime.maxMemory(); | |
var allocatedMemory = runtime.totalMemory(); | |
var freeMemory = runtime.freeMemory(); | |
return "<hr/>Free memory: " & numberFormat(round((maxMemory-allocatedMemory+freeMemory) / 1024 / 1024), ',') & "MB (#round((maxMemory-allocatedMemory+freeMemory)/maxMemory *100)#%)<br/>" | |
& "Used memory: #round((allocatedMemory-freeMemory)/maxMemory *100)#%<br/>" | |
& "Allocated: " & round(allocatedMemory/maxMemory *100) & "%<br/>" | |
& "Max memory: " & round(maxMemory / 1024 /1024) & "MB<hr/>"; | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment