ajermakovics / jvm-mon

Console-based JVM monitoring tool
https://ajermakovics.github.io/jvm-mon/
Other
1.48k stars 117 forks source link

Calculating values for heap usage for plotting the graph #31

Open ReasonablyAnon opened 4 years ago

ReasonablyAnon commented 4 years ago

How can I get plotted values of heap usage graph in text file ( possibly comma separated ) ? Also, I couldn't understand how exactly are you getting/calculating those values for plotting ? Can you please tell this approach, that would be more beneficial for me. Thanks in advance, means a lot.

ajermakovics commented 4 years ago

Hi,

It gets memory values from Java itself using [Runtime](https://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#totalMemory()): https://github.com/ajermakovics/jvm-mon/blob/master/jvm-mon-go/src/main/java/jvmmon/core/JvmMon.java#L32

If you are running 0.3 then you could add some code to write values into a text file: https://github.com/ajermakovics/jvm-mon/blob/master/src/dist/jvm-mon.js#L142 there already should be a jvm-mon.js file in your install.

ReasonablyAnon commented 4 years ago

Thank you so much for the reply.

I mean are you calculating those values after GC happens or before GC happens. At what point of process , are you determining to get that heap usage value during the process is running ? Thats why, you are able to get many heap usage values 'throughout the whole process' for plotting right ? To get various heap usage values thoughout the process, that logic, I am trying to understand.

ajermakovics commented 4 years ago

Ah, ok. It just polls memory usage every 1 second.