How to measure actual memory usage of an application or process ?
How to find how much a specific process use ?
Just run pmem.sh script with a process name ! such as..
$ ./pmem.sh chrome
chrome's memory usage : 60.9 %
As you can see, you can find out what percentage does the process use of all memory.
$ cat pmem.sh
#!/bin/bash
if [ "$1" == "" ]; then
echo "Please enter process name"
exit 0
fi
p_count=`ps -eo comm | grep -wc "$1"`
if [ "$p_count" == "0" ]; then
echo "Error: '$1' process don't exist"
exit 0
fi
mem_usage=`ps -eo pmem,comm | grep -we "$1" | awk -F" " '{print $1}' | paste -sd+ | bc`
echo "$1's memory usage : $mem_usage %"
exit 0
No comments:
Post a Comment