I have a VPS with 512MB RAM with 1GB Burst from TelVPS. There is no swap space for the VPS.
I had a discussion regarding this with my service provider but they said that they dont provide swap space for VPS, Can I add SWAP space of my own?
I have the following setup:
- Apache2/Passenger
- Ruby on Rails 2,3
- MySQL
- Sendmail.
I have 3 rails application running, but they are test apps with low to no traffic.
top and the VPS control panel shows my system is using around 880MB of RAM. But the process list result of top does not show any process eating memory. I have read http://www.linuxatemyram.com/. But following is the output of free -m
root@serveme:/var/www# free -m
total used free shared buffers cached
Mem: 1024 819 204 0 0 0
-/+ buffers/cache: 819 204
Swap: 0 0 0
I have two questions about this situation:
1). How to resolve memory eating issue? (Please let me know if more information is needed)
2). Can I add SWAP space? If yes, how? Is that safe to add swap space after setting up the system?
EDIT:
1). Memory:
I ran ps -axu --sort -rss | head -n 10 as suggested by Fox(in comments) and I found that
my sunspot (a rails gem for fulltext search based on solr) was eating memory. There are options to limit memory usage for sunspot.
2). Swap space
Followed the steps by Tom in accepted answer.

ps -axu --sort -rss | head -n 10? (edit: doing pretty much the same thing B14D3 is suggesting) – Fox Dec 17 '11 at 9:37