I have a VPS running CentOS with some PHP sites. It's been running fine for weeks.
Recently it has become slower and slower (both website usage and when logged in via SSH). I have determined that it consistently uses more and more memory until it maxes out, then I have to reboot it, the memory usage goes back down, but then constantly climbs again.
What could be causing this and how can I analyze/solve it?
here is my top:
While running top, you can press M (capital m) to sort by memory usage. You can watch for what is using the most memory there.
If Apache is the problem, you can work around memory leaks by setting or lowering the MaxRequestsPerChild parameter. This will kill off an Apache worker process after it has processed the specified number of requests.
Any program could be leaking memory; the best thing to do is to run sysstat (sar) at regular intervals via cron to capture process information periodically, and then look at the memory consumption of all your processes over time and see which one(s) are growing (or if there are more processes over time).