BASH Memory

From Indie IT Wiki
Jump to: navigation, search


Display True Memory Usage

Most people use the free command to show RAM usage, but read it wrong. In the example below, it looks like the computer only has 67 MB available. However, Linux keeps data stored in RAM when reading disks and some more for programs just in case they need it, effectively being greedy for better performance.

What the Linux system is actually using or needs to use is shown on the 3rd line!

free -m
         total      used     free   shared     buffers     cached
Mem:      4049      3982       67        0          16       3530
-/+ buffers/cache:   435     3614
Swap:     6142        53     6088

So, a slightly tweaked command would be...

free -m | awk 'NR==3 {print $4 " MB free."}'
3614 MB free.

(The above command for awk translates to "print 4th column of third line" :-)

Thanks to Thoughts by Clag G.



sudo -i
cd /tmp
sudo chmod +x
sudo cp -av /usr/local/bin/psmem
which psmem


sudo psmem
sudo psmem | grep -E thunderbird

For more information see the GitHub page, and thanks to Epety ET.