To release reserved, but at the same time unused RAM by JVM to OS, Jelastic uses a special Garbage Collector agent. We have switched to a modern Garbage Collector that Jelastic selects, based on cloudlets allocated for a container.Garbage Collection (GC) is a form of automatic memory management. The garbage collector attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program. In such a way you can cut your costs by not paying for unused resources.
Releasing RAM with Jelastic GC Agent
Jelastic GC agent is enabled for all newly created Java application servers by default.
It works only for two kinds of Garbage Collection:-XX:+UseParNewGC (if -Xmx < 8000m)
-XX:+UseG1GC (if -Xmx >= 8000m)
These parameters can be customized but if you specify any other GC manually then calling full GC will be disabled.
By default, the Garbage Collection process is running every 15 minutes (beginning from every JVM start) to force freeing of unused application memory. The period of checks can be changed based on your requirements.
To customize the settings or disable GC agent navigate to the server > variables.conf file for Tomcat, TomEE or Jetty application server.
Note: GC agent for GlassFish can be configured or disabled via the GlassFish admin panel in gfcluster-config > JVM Settings > JVM Options.
A. Enable/Disable GC Agent
Jelastic GC agent is enabled by default (see default settings above).
If you think that our default GC settings may cause performance degradation for your application, please comment the following line and restart the server:
B. Change Period of Checks
To change the time period of checks, specify the duration between calls of full GC in seconds as shown below:
C. Enable Debug mode
You can also enable debug mode in the following way:
Note that you can use both custom settings (changed period of checks and enabling debug) together:
Save your edits and Restart the server to apply the changes.
Check the Result
The result of the configured periodical checks and RAM releasing can be viewed in the following ways:
1. The amount of available free memory (in bytes) can be seen in the logs if the debug mode is enabled (see above).
Navigate to Log > catalina files, to get the required data.
2. Monitor the Statistics to see the decrease in the RAM usage with the enabled GC agent.
Using this method, you can improve your application memory management which will lead to a reduction of RAM consumption by JVM. As a result, you will save your money and increase the performance of your application.