Linux – Excessive memory usage on a Go Daddy VPS

godaddyjavalinuxmemory usage

I have a Go Daddy Linux VPS, hosting a Java server and a few other things. Evidently we are running out of memory:

[user@xxx ~]$ free -m
total       used       free     shared    buffers     cached
Mem:          4096       4090          5          0          0          0
-/+ buffers/cache:       4090          5
Swap:            0          0          0
[user@xxx ~]$

But here comes the interesting part. I can't find the memory hog with "ps" – all the listed processes have a "reasonable" memory usage (under 2%), but the system is still out of memory.

Trying to increase the available VM by mounting a swap leads to an error ("Operation not permitted"). I found that this is a limitation of OpenVZ – only the host should swap to disk drives.

The output of "vmstat" is not very useful:

[user@xxx ~]$ vmstat
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
0  0      0   5548      0      0    0    0    22   105    0   15  0  1 99  0  0
[user@xxx ~]$

Any ideas how can I find the exact cause of the free memory shortage without blindly killing services and waiting for the problem to repeat? Thanks in advance!

Best Answer

Were you getting out of memory errors with a particular application? Or do you have a performance issue? What specifically leads you to believe that your are out of memory (aside from the 'free -m' command).

The first thing to look for is a LOT of processes using a small amount of memory. If you have 100 processes only using 128mb of memory you will be short of memory for example.

It's very normal to see almost 100% of your memory used in Linux. However I don't know enough about how this works within your particular VPS provider to know if your usage is considered normal. With my own VPS provider I have 24mb / 512m free and it's purring along nicely. If required it will dump out the almost 400mb of cached data it has.