I am calculating used memory with the following ColdFusion code.
runtime = CreateObject("java", "java.lang.Runtime").getRuntime();
Then in a loop I do the following to calculate the used memory.
var usedGB = (runtime.totalMemory() - runtime.freeMemory()) / 1024.^3; // bytes -> KB -> MB -> GB
This tells me that almost 200 MB are used right from the beginning of my page. Is this how much is being used by the CF server or is this just some overhead from my page?
Runtime gives you the amount of heap which has been allocated. This includes objects and TLABs so the actual amount of memory used is slightly less than this. This the amount used by the whole JVM including ColdFusion server or any other application or library you are running. There is no way to track how much an individual page or thread is using and memory is not local to a page or a thread.
Both totalMemory
and freeMemory
report usage by JVM - which I expect to be the CF server (unless you're running other stuff in the same JVM as well). Plus any JVM overhead of course.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With