Because ColdFusion is an enterprise Java application, the
Java Virtual Machine (JVM) is the software component that most influences
performance. Different JVMs from different vendors and different
versions of the same JVM from the same vendor have different performance
characteristics. You might benefit from changing the JVM that you
are using with ColdFusion.
ColdFusion contains an embedded version of Tomcat as the application
server and the Sun 1.6 version of the JVM. By contrast, ColdFusion
for J2EE running on IBM WebSphere Application Server uses the JVM
that WebSphere is configured to use.
To configure ColdFusion to use a different JVM, edit the cf_root/runtime/lib/jvm.config
file with a text editor by modifying the value of java.home to point
to the root directory of the JVM to use. Alternatively, you can switch
to a different JVM in the ColdFusion Administrator on the Java and
JVM Settings page.
Because switching the JVM changes the software environment significantly,
do so first in a development or testing environment. Also, fully
test your ColdFusion applications before you make the change on
a production server.
The JVM performs memory management and can have a significant
effect on your performance depending on how you configure the JVM.
The most important settings for the JVM are the initial heap size
and maximum heap size. The initial heap size represents the amount
of memory that the JVM uses on startup; the maximum heap size represents
the amount of memory that the JVM can use. You can modify these
settings in the ColdFusion Administrator on the Java and JVM Settings
page. The Initial Memory Size setting specifies the initial heap
size; the Maximum Memory Size setting specifies the maximum heap
size. The JVM arguments for initial heap size and maximum heap size
are -XmsNm and -XmxNm respectively,
where N is the size of the heap in megabytes (MB).
These JVM arguments are stored in the jvm.config file, in the value
of the java.args setting.
The default maximum heap size is set to 512 MB in ColdFusion.
For best performance, set the initial heap size and the maximum
heap size to the same value. Determining the optimal size for the
heap to run the applications on your ColdFusion server results in
improved performance. Setting the value too high can result in poorer
performance because of the higher degree of garbage collection and
internal memory management required for the larger heap. Conversely,
setting the heap size too small can result in a java.lang.OutOfMemoryError
error if your application tries to use more memory than is available
to it.
The best way to find the optimal heap size is to run your application
under simulated peak load with a large heap and monitor how much
memory your application actually uses. If you find that your application
uses only 180 MB of memory, for example, you might see performance
benefit from reducing your heap size to 256 MB.
The java.lang.OutOfMemoryError error can occur in other, more
complicated, conditions. One common cause of the error is when objects
fill up the heap's permanent generation, which defaults to 64 MB.
You can increase the value, for example, to 128 MB, by adding the
following JVM argument to the Java and JVM Settings page of the
ColdFusion Administrator:
-XX:MaxPermSize=128m.
Physical hardware memory is an important consideration when determining
the optimal heap size. Setting the maximum heap size to a value
that exceeds the amount of free physical memory causes severe performance
degradation. For example, if you have only 512 MB of physical memory,
do not set the maximum heap size to 512 MB. Because the operating
system and other running applications use memory, much less than
512 MB of memory is available for the JVM process. it is important
to have hardware that meets the requirements of your software application.
For best results, run on server hardware with 1 GB or more of physical
memory.
The Server Monitor Summary page monitors the JVM’s memory usage.
Use this information when determining the optimal heap size.