Reputation: 573
JConsole or J VisualVM show the maximum heap size and the current heap utilization. How can I get the same values, during the lifespan of an application, using a command-line based tool, such as jstat?
From the metrics that I collect with jstat -gc (S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT), how can I compute the (single value) heap utilization that is given by JConsole/Visual VM?
Upvotes: 2
Views: 1891
Reputation: 1
If you have the jstat measurement results, you need to understand the Heap situation and the trend of GC occurrence. If you don't have the analysis tool, you can use the link below first.
https://visualgc.streamlit.app/Jstat_Analyzer
Upvotes: 0
Reputation: 1267
You may use some bash command along with jstat to get desired result. For example, following will give you Eden space utilized.
jstat -gc <PID> | sed -n 2p | awk '{ print $6; }'
Upvotes: 1
Reputation: 5443
Beyond using jstat
or jps
, what you're asking about is using a JMX client such as jmxterm, to access these metrics on the server. Another option would be to include Jolokia with the server application, which would expose MBeans on the server over HTTP, such that you could use cURL in a Bash script, for example.
Upvotes: 1