Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does java.lang.Runtime report the memory usage for the whole Coldfusion server or just one page?

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?

like image 887
danmcardle Avatar asked Dec 26 '12 20:12

danmcardle


2 Answers

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.

like image 55
Peter Lawrey Avatar answered Oct 12 '22 11:10

Peter Lawrey


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.

like image 26
Andrey Nudko Avatar answered Oct 12 '22 12:10

Andrey Nudko