How to Optimize JVM to utilize less resources
I am using Apache tomcat 7.02 as a server.I created an application using sphinx4 and deployed it on apache tomcat server.Since this Sphinx4 app开发者_开发问答lication requires a lot of memory to execute.So for that purpose i alloted lot of memory as java Heap space(export CATALINA_OPTS="-Xms1536m -Xmx1536m"). The Server on which i have deployed the server is a 64bit System with Debian Lenny on it,along with 2Gb of RAM. I created a Servlet,post data to it,get the results... When i run it for 10 users it takes about 8 minutes to process but if i run it for 100 users simultaneously,thn it shows this on tomcat status
Free memory: 37.0 MB Total memory: 1484.81 MB Max memory: 1484.81 MB
I also tried using System.gc(),but it did no gud.So is there any way through which i can check the memory status of JVM and free it when needed?
You need to determine where resources are being using. I suggest you use a memory profiler and change the program to consume less memory.
If you are using a 64-bit JVM you can use the -XX:+UseCompressedOops
to reduce memory consumption (it uses 32-bit references instead of 64-bit references)
EDIT: If you cannot tune your application it may be worth considering upgrading your server. A 24 GB server can cost around £1,800 and might allow you to scale to 1000 users without a code change. ;)
精彩评论