My VPS is continously running out of memory, my apache server goes down and when I login to reboot, I get a "memory fault" error and have to reboot through my hosting company dashboard.
However, before rebooting I'm able to look at the memory usage with top
, and I see nothing suspicious. Mysqld sometimes peaking at 6% memory, a couple of php-cgi7 processes at 1%, and that's it, all other processes don't seem to consume much memory.
So is top
missing something for some reason? What else can I do to debug this situation?
I guess by the time you log in the process causing the problem is gone. Try logging in and using top to work out what is using memory when the system is working normally but has been up for a while.
As @yoonix suggests, check your system log. To find this log google something like "(os name) system log location". Look at that file with your text editor of choice for applicable messages.
You can refer here to find out how your OS decides which processes to kill.
As outlined on this page (which is a bit old now), you can use something like this to find out what's been killed
You should see entries something like this
Use any monitoring system or for example collectd and its Processes plugin to gather per-process resource usage statistics. Afterwards you can check from the graphs which process or processes are misbehaving and eating up all the memory, and you'll be able to see if the memory usage slowly creeps up or does it just suddenly blow up.