VPS : How to deal to servers without swap

javamemory usagevps

I have recently deployed a java application on a VPS but It keeps crashing because the JVM runs out of memory after a while.
I never had this issue on other 'low memory' servers thanks to the swap but on this VPS, It's different: There is no swap and only 50% of the actual 512megs of ram "can be used" (they say 256mbs are garanteed). Is there any way I can limit the memory consumption ? I have tried to use the xms variables but It didn't help much. I have also tried to put swap into a file but It's not allowed apparently.

Thanks in advance

Best Answer

Yes, you could limit java memory consumption. See for example here: http://viralpatel.net/blogs/2009/01/jvm-java-increase-heap-size-setting-heap-size-jvm-heap.html

But 256M is very small amount for java world. I suggest you to get a better vps.