Last active
August 29, 2015 14:07
-
-
Save safchain/f86500dfcd97983701df to your computer and use it in GitHub Desktop.
Java Memory Usage
This file contains 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
#!/bin/sh | |
if [ -z "$1" ] | |
then | |
echo "Usage: $0 <java process name>" | |
exit 1 | |
fi | |
PID=`jps | grep $1 | awk '{print \$1}'` | |
jmap -heap $PID 2>/dev/null > /tmp/jheap | |
CAPACITY=`grep capacity /tmp/jheap | grep = | awk '{TOTAL += $3} END{print TOTAL}'` | |
USED=`grep used /tmp/jheap | grep = | awk '{TOTAL += $3} END{print TOTAL}'` | |
PERCENT=$(( $USED * 100 / $CAPACITY )) | |
echo total:$CAPACITY used:$USED percent used:$PERCENT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment