Page tree
Skip to end of metadata
Go to start of metadata

Monitor application server's Java process

As BellaDati is a Java application run on the application server and JVM tools like VisualVM can be used for monitoring the BellaDati's usage of memory, threads, etc. and can be a source of valuable information in solving performance issues.

There are 2 ways how the VisualVM can connect to the Java process of the running application server which host BellaDati:

  • directly - when VisualVM can be run on the same machine as the application server or
  • JMX - when VisualVM can't be run on the same server, e.g. application server is run on machine which has no UI or is run on some managed server you have no access to.

Enable JMX

To enable JMX connection to the Java process running application server following JVM options need to be added to it:

Once JVM options are added and application server is restarted, VisualVM can be connected to it by creating JMX connection to <server-address>:9010. In case the port is not publicly available and SSH connection is possible, port can be made available by port forwarding, e.g. on Linux based systems via:

ssh -L 9010:localhost:9010 <user>@<host>

Collect GC Logs

In case of memory issues, Java process running application server can be configured to collect garbage collection (GC) logs as well as to generate a heap dump in case of OutOfMemoryError. Also, switching the type of garbage collection algorithm can improve performance. To enable GC logs generation and heap dump generation as well as switch GC algorithm to G1 add following JVM options in the application server:



  • <gc-log-dir> is the absolute path to the directory in which GC logs should be stored and
  • <heap-dump-dir> is the absolute path to the directory in which the generated heap dump should be stored.

GC logs files rotation

The above configuration enables the GC log file rotation after the file reaches 50MB. Up-to 20 files are kept before the old ones are removed.

GC log file name

The above configuration generates a new GC log file name every time application server is started. The %t part in the file name converts to the current date & time of the server. The generated file name is kept for the whole run of the application server, even after log file rotation. Once the application server is restarted a new file name is generated and old ones are not deleted, old files must be deleted manually. Alternative is to exclude the %t part, but then existing GC log(s) needs to be copied before application server is restarted otherwise they will be overwritten.

  • No labels