Question

free-m doesnt match with ps aux count

  • Posted on January 20, 2015
  • leoAsked by leo

Hi,

I got a 2GB memory droplet and seems like my free-m is not couting correct my free memory OR something is using more than it should…

I did some reasearch and i found that i can “count” my usar memory by this command:

ps -e -orss=,args= | sort -b -k1,1n | pr -TW$COLUMNS

Quick math all my main process are using 500MB memory… with the minor ones… it should reach 600MB top.

but free -m show that i only have 300MB left… and 800MB cached…

Just to you know i running 4 nodejs applications (3 ghost blogs and 1 express)

Any thoughts about it?


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

On Linux, cached memory is still available for use. So when looking at the output of free -m the “available” column is likely what you want to be looking at rather than the “free” one.

The output of ps can also be a bit misleading. This blog post covering memory usage on Linux has a good explanation:

Why ps is “wrong”

Depending on how you look at it, ps is not reporting the real memory usage of processes. What it is really doing is showing how much real memory each process would take up if it were the only process running. Of course, a typical Linux machine has several dozen processes running at any given time, which means that the VSZ and RSS numbers reported by ps are almost definitely “wrong”. In order to understand why, it is necessary to learn how Linux handles shared libraries in programs.