Invisible processes using all of system memory

I have a VPS (Ubuntu 14.04) with 512MB of RAM. This used to be quite enough, but for a while, this has been causing problems -- something is eating up all of that memory, and my debugging has left me clueless.

I have turned off Apache, MySQL, etc, and I am still using 90% of the memory. It just boggles my mind. I have restarted multiple times.

Screenshot

I'm sure I'm just being dumb, but I'd appreciate any wisdom that this community could impart concerning this issue.


Solution 1:

You have only 500 MB of RAM installed. I would not be surprised that most of it is in use, given those little resources.

On the other hand, htop sums up both the really used memory (allocated by applications) and the cache (used by the system to cache disk access, but immediately available to applications if needed). Therefore the "non-free" memory amount looks much greater than it actually is.

Check the output of free -h, it will give you more detail:

            total        used        free      shared  buff/cache   available
Mem:          11G        1,2G        9,2G         30M        1,2G         10G
Swap:        7,5G          0B        7,5G

While the used column shows you how much memory is in use in total (like htop), the available column shows you the amount of memory that is allocatable by applications. This is usually the number that is interesting to end-users.

Alternative output format (copied from the link at the bottom):

             total       used       free     shared    buffers     cached
Mem:          1504       1491         13          0         91        764
-/+ buffers/cache:        635        869
Swap:         2047          6       2041

In this format, the interesting number of allocatable RAM is located in the free column, but in the -/+ buffers/cache row.

Related must-read website: http://www.linuxatemyram.com/