Is there a way to enable swap space in a VPS?

Ask questions about dedicated servers here and we and other users will do our best to answer them. Please also refer to the self-help section for tutorials and answers to the most commonly asked questions.
Post Reply
LEOcab
New to forums
New to forums
Posts: 13
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Tue Sep 25, 2012 7:28 am

Is there a way to enable swap space in a VPS?

Post by LEOcab »

I'm afraid one of these days Minecraft/Bukkit/some plugin will come up with a new memory leak and my server will start crashing all the time because Java runs out of memory. I've seen it happen before but when I hosted at home I had a swap partition to back me up. Is there a way to enable swap space in my VPS? I see there's a file called 'swap.img' at the file system root. Is that it? If so, how do I mount it?

Thanks in advance! :)

PS: I have CentOS 6.2.
User avatar
Edge100x
Founder
Founder
Posts: 13112
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Is there a way to enable swap space in a VPS?

Post by Edge100x »

I don't recommend using swap very much because it kills performance and also affects the performance of other customers. But, you can use that existing pre-created swapfile by just entering:

swapon /swap.img
LEOcab
New to forums
New to forums
Posts: 13
Joined: Tue Sep 25, 2012 7:28 am

Re: Is there a way to enable swap space in a VPS?

Post by LEOcab »

Edge100x wrote:I don't recommend using swap very much because it kills performance and also affects the performance of other customers. But, you can use that existing pre-created swapfile by just entering:

swapon /swap.img
For some reason CentOS doesn't seem to need swap; I used Slackware before and it always wrote up to a few dozen megabytes to swap at random times even though Bukkit reported less than 50% memory usage. CentOS's memory readings are closer to what I expect (I left roughly 128MB out of my startup script for OS usage and so far that's the lowest number it's shown under free memory) so maybe I won't need it at all. :D
Post Reply