Get ColdFusion memory usage

October 30, 2009 by Jean

Retrieve the memory usage of the ColdFusion server using Java functions:

variables.runtime = createObject("java","java.lang.Runtime").getRuntime();
variables.freeMemory = variables.runtime.freeMemory() / 1024 / 1024;
variables.totalMemory = variables.runtime.totalMemory() / 1024 / 1024;
variables.percentFreeAllocated = round((variables.freeMemory / variables.totalMemory) * 100);

In: ColdFusion