Skip to content

Instantly share code, notes, and snippets.

@mikeslattery
Last active May 24, 2021 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeslattery/1dff7b9eb1b9acad5a0f6a78e35a8c8c to your computer and use it in GitHub Desktop.
Save mikeslattery/1dff7b9eb1b9acad5a0f6a78e35a8c8c to your computer and use it in GitHub Desktop.
Monitor memory use of all running java applications
#!/bin/bash
# Display memory useage of all running java processes
pidof java | xargs -r ps -f
echo ''
echo $'PID\t% MEM\tTMEM\tGC Time'
while true; do
for pid in $(pidof java); do
echo -n "$pid "
jstat -gc $pid | awk 'NR>1{ print 100.0 * $8 / $7, $8, $17}'
sleep 2
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment