Published:
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
So last week I started to get error alerts from my server around the time a new blog post was auto published. A quick ssh in and I could see that java (ie railo) was eating a whole load of cpu cycles but was not really consuming a lot of memory. It was at this point that it occurred to me that I had never changed the default memory settings when I installed railo.
Basically I was running railo with a memory limit of 256m on a machine that had 4gb free...well duh of course I was going to have problems.
Changing the JVM memory Settings
To change the memory settings for railo you need to locate the setenv.sh file. This is located at "{railoinstalldir}/tomcat/bin/setenv.sh".
Open this file for editing and look for this line:
JAVA_OPTS="-Xms128m -Xmx256m -XX:MaxPermSize=64m ";
There are three settings in megabytes here that we can modify:
- Xms: The minimum heap size.
- Xmx: The maximum heap size.
- MaxPermSize: The max perm space size.
Its tempting to just max all the values out, but the bigger the values the harder garbage collection has to work. Also many people advocate setting Xms and Xmx to the same value to remove any lag from the jvm expanding its memory footprint from the min up to the max, however for my little server I dont mind a little lag if I dont need to use the entire max value.
For myself I doubled the Xms value since I knew I was already hitting 256m memory usage and I set the Xmx value to 1024m to begin with as it is well within my free memory availablility. Finally I doubled the maxpermsize.
I will admit this is not a very scientific approach, but later on down the line when I have time I will hook up JConsole and really see whats going on.
Reader Comments