Heap Dump and Remote Tomcat 8-OpenJDK 8 Memory Monitoring

Date February 13, 2017

Memory problem.. the thorn of web apps… I have to connect to my remote server to monitor its memory usage and produce a heap dump.
Bellow is the steps I had to configure the server to allow me to connect a remote monitor tool.

Requirement: VisualVM app, download here

  1. Access your catalina.sh file.
  2. Look for JAVA_OPTS, if none found, you can add your own.
  3. Add …
    1
    
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/

    to the line if found, if not, you can do

    1
    
    JAVA_OPTS="JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/"

    The above code will force a heamp dump when the server encounter a out-of-mem exception.

  4. Next, to enable remote memory monitoring, add these commands after the line above, within the quotation mark, add proper spacing after each command…
    1
    2
    3
    4
    
    -Dcom.sun.management.jmxremote.port=<port_num>
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=false
    -Djava.rmi.server.hostname=<host_ip_add>
  5. Now, run VisualVM and create a new JMX remote connection, under the CONNECTION field, add host_ip_address:port_num
    ex. 111.111.1.1:5555

Congrats! You should now be able to connect to your server and monitor your memory usage!

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>