If you believe that the default Jelastic settings of garbage collector can have a negative impact on your application, you can tune them according to the requirements of your app. We recommend to customize these configurations only if you fully understand the impact of such changes on your app’s performance.
You can set a custom GC parameter based on your application requirements by:
- editing the variables.conf file of your Tomcat, TomEE or Jetty server
- editing JVM option in the admin panel of GlassFish server
1. To configure Tomcat, TomEE or Jetty open Conf files of your Java server.
2. Navigate to the server > variables.conf file.
3. In the opened variables.conf file you can configure garbage collector settings by stating the needed parameter in the following format:-XX:+UseParNewGC
4. While configuring GlassFish, you need to use the same format of GC parameter.
Open GlassFish admin panel, navigate to Configurations > gfcluster-config > JVM Settings > JVM Options and edit the appropriate JVM Option as it is shown in the picture below.
5. After this, only the specified garbage collector will be used while starting your Java server without taking into consideration the amount of allocated resources.
|Note that Jelastic GC agent works only with two kinds of Garbage Collector:|
6. Also, you can reduce the usage of CPU power by GC and control how JVM handles its heap memory. For that you need to tune the frequency of GC processes by stating -Xmx and -Xms switches.-Xmx switch is used to start the JVM with a higher maximum heap memory and to release CPU time for the important processes.
-Xms parameter is stated to ensure that the size of JVM’s initial heap memory is equal to the maximum allocated memory (Scaling Limit).
-Xmx< size >m
These parameters should be specified in the variables.conf file for Tomcat,TomEE and Jetty or in JVM Options for GlassFish.
-Xms< size >m