Created
April 30, 2020 00:07
-
-
Save henrikno/4eabd7a4cb5be2f37f9d86145e5cae39 to your computer and use it in GitHub Desktop.
Get current/max memory usage for java process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PID=$(jps | grep Main | awk '{print $1}') | |
CUR=$(jstat -gc $PID | tail -n 1 | awk '{split($0,a," "); sum=a[3]+a[4]+a[6]+a[8]; print sum/1024}') | |
MAX=$(jstat -gccapacity $PID | tail -n 1 | awk '{split($0,a," "); sum=a[2]+a[8]; print sum/1024}') | |
echo $CUR/$MAX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment