Memory Usage on Linux box does not match up with `free`

However, when I run ps aux, the memory usage of all processes only comes out to 295.9MB, which is a far cry from the 1.7GB of memory that free reports as used.

Why is there such a discrepancy?

Because linux memory management is just plain wacky? A very large graph of linux innards laid out in all their glory

Jokes aside, seriously - memory management in Linux is not a simple beast. There are different ways of "viewing" what is "Free" and "Used", and even the most obvious number might not be so obvious once you look into it. I think you might want to quantify what your definition of "used" is, and then apply that definition to the numbers you're looking at, especially with regard to what numbers your using.

  1. Are you taking into account shared memory? Depending on how you count "used", a program's memory can be small or much, much larger. Do you count shared memory separately, or as if each process attached to it owns it?

  2. Shared libraries can also have the same behavior: a program loads a library (libmylibrary.so) that is shared with another program. One view of memory says that the library doesn't count towards the memory used; another view says that it not only does, but it will count it twice - once for the program that just used it and again for the program that was already using it, because each program will need a virtual memory mapping for the library to work. A third view says the library really occupies only the memory that was needed to load it. Which one is the "correct" view of memory?

  3. Disk cache/buffers can also create complicated views of what is and isn't "used" vs. "free". The system will use up memory that is not in use by programs, but if it needs the memory to load a program, the cache is discarded and re-used to load an instance of that program. You could easily have only 3Mbyte of code loaded in memory but be consuming 600Mbyte of disk cache. Again, which one is the "correct" view?