I would like to monitor java 8 processes on a Linux Centos system and be able to see how much memory they are using. I would prefer to use shell utilities as I wish to eventually feed the output into our central monitoring system
I am also baffled by the -Xmx options in java8 which seem to have no effect on the amount of memory used
Here is a script to get ps info on java programs
for jvm in `sudo -u services jps|awk '/.jar/ {print $1}'`; do ps up $jvm;done
output
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
services 1409 0.0 10.8 4672536 872440 ? Tl Jun03 3:53 /usr/java/lates
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
services 1574 0.0 11.4 4743036 925536 ? Sl Jun03 3:13 /usr/java/lates
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
services 19839 0.7 10.9 4735664 881420 ? Sl 09:43 0:15 /usr/java/lates
Here are some settings from the programs
sudo -u services jps -lvm
1409 /usr/local/content-adapters/pmc-adapter/pmc-adapter.jar -Xmx1024m -Xms512m
1574 /usr/local/content-adapters/tools-adapter/tools-adapter.jar -Xmx512m
20685 sun.tools.jps.Jps -lvm -Dapplication.home=/usr/java/jdk1.8.0_65 -Xms8m
19839 /usr/local/content-adapters/cas-adapter/cas-adapter.jar
some info on the server defaults
java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
intx CompilerThreadStackSize = 0 {pd product}
uintx ErgoHeapSizeLimit = 0 {product}
uintx HeapSizePerGCThread = 87241520 {product}
uintx InitialHeapSize := 130023424 {product}
uintx LargePageHeapSizeThreshold = 134217728 {product}
uintx MaxHeapSize := 2063597568 {product}
intx ThreadStackSize = 1024 {pd product}
intx VMThreadStackSize = 1024 {pd product}
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
If I use jstat, I can't make the various "use" numbers add up to either the 4.5GiB VSZ numbers above or the 800-900MiB RSS
My questions are
- how do I relate the -Xmx and other settings to the amount of actual memory used?
- how do I use jstat to show the amount of memory in use?
- presumably the difference in VSZ and RSS is due to some kind of shared resources that all the java programs use. How can I estimate or find this metric?
