I wanted to see how much memory Firefox 4 use, not for any particular reason. So, I quickly wrote one short script:
#ff_pid=1234 max_mem=2048 max_bar_len=100 while :; do ff_pid=$(ps -e -o pid,cmd | grep firefox-bin$ | grep -o '^ *[0-9]*') if [[ $ff_pid ]]; then mem_mb=$(($(ps -p $ff_pid -o rss=)/1024)) bar_len=$((max_bar_len*mem_mb/max_mem)) printf "$(date +%H:%M) %4dM [%3d%%] \033[41m%${bar_len}s\033[42m%$((max_bar_len-bar_len))s\033[0m\n" $mem_mb $((100*mem_mb/max_mem)) '' '' else printf "%s ---\n" $(date +%H:%M) fi sleep 60 done | tee ff_mem.txt | awk '{if(m!=$2){print $0;m=$2}}'
max_mem specifies the system memory in MB. max_bar_len is the how long the bar can be in character if memory use is 100%. Because I always run additional Firefox instance (profile, using --no-remote), so I have to make sure I get the main Firefox’s PID, which is the one I want to monitor. The awk is used for removing consecutive lines of same amount memory use. You can take it out if you want to see minute by minute results.
Here is a result after I started up Firefox today:
I haven’t fully used Firefox to visit sites I often do. Normally, after it reaches about 20%, I restart Firefox. I want to see if it will go down after it reaches 50%.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.