Using…too …much memory ……..

So about 2 months ago,  I installed ChruBuntu on my Acer Chromebook and  have been loving it for the most part.  However there is one nagging issue and it’s the memory usage that slows the system to a crawl when visiting some rich content websites (e.g. Youtube, FB, Gmail, etc).

A normal task would be to simply kill the browser process, ie. Firefox when the system gets sluggish. However by that time, opening a terminal window and then waiting for inputs to appear on the screen was getting ridiculous.  On average it would take me 2-4 minutes,  before I could kill the FIrefox process.

My solution : A shell script that runs every minute and monitors the memory usage.  The moment free memory drops below a certain threshold, all firefox (and Chrome) processes are executed with prejudice  !!

Here is the script

————————————————————————————

#!/bin/sh

/usr/bin/free -m | grep Mem | grep -v grep | awk ‘{print $4}’ > /tmp/freem1.log
mem=$(cat /tmp/freem1.log )
lmt=”95″
#echo “memory usage is $mem\n”

if [ “$mem” -gt “$lmt” ]
then
echo “Memory usage is fine at $mem \n”
else
echo “Memory is Less than $lmt at $mem. Killing chrome and firefox\n”

ps ax | grep firefox | grep -v grep| awk ‘{print $1}’ | xargs kill -9
ps ax | grep chrome | grep -v grep| awk ‘{print $1}’ | xargs kill -9
fi

————————————————–

Leave a Reply

Your email address will not be published. Required fields are marked *