0

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!

Georgi Hristozov
  • 702
  • 1
  • 4
  • 13

1 Answers1

1

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.

Mike F
  • 340
  • 1
  • 6
  • The Java application is trying to execute shell scripts, which leads to out of memory exceptions. The number of processes is big, but summing the numbers from "ps" is still far from 100%. By the way, I can't believe the VM is not using buffers and cache - I get zeroes there even if I have free memory, which is not the case on my Linux desktop. – Georgi Hristozov Jun 20 '11 at 19:03
  • Some virtual environments (and apparently your) do all the caching on the host side. Others do not. – Mike F Jun 21 '11 at 03:35
  • What specific java.lang.OutOfMemory exception are you getting? Is it the heap/permgen/etc. What does the exact java.lang.OutOfMemory exception look like in the stack trace? It might be that your Java memory settings are too low (or high). Try invoking variations of java -Xmx512m or something like that and see if it improves things. – Mike F Jun 21 '11 at 03:38
  • The default maximum memory of Java has changed somewhat. And i'm not certain what the defaults are in Linux now these days. It used to be just 64mb. Now there there is a whole formula for how its setting. What is your version of Java? – Mike F Jun 21 '11 at 03:39