Posted by HostsVault | Posted in Tips-And-Tricks | Posted on 13-05-2009-05-2008
Many Java application users may face this problem that their java virtual machine JVM is eating alot of memory , infact Java is greedy when allocting memory it will try allocating all the memory it can so and wil share it with other instances but this is a problem specially when your on a VPS and have limited memory .
You can limit the amount of memory Java application uses by using this command when compiling your application :
/usr/local/jdk/bin/javac -J-Xmx”amount of ram” application.java
so for example to allocate 128 MB RAM only you run
/usr/local/jdk/bin/javac -J-Xmx128 application.java
You can limit the amount of m This way your application wouldn’t allocate more than 128 MB RAM.