1

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?

user252816
  • 563
  • 4
  • 12
  • 21

2 Answers2

1

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.

ck1
  • 5,243
  • 1
  • 21
  • 25
0

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; }'
nitzien
  • 1,117
  • 9
  • 23