WebSphere: Generating Heap Dump using Jython

Kamen Tarlov
Kamen Tarlov
CEO & DevOps Lead
Reading time: 2 mins.
Last Updated: 12.02.2024

Table of Contents

Java Virtual Machine (JVM) Heap Space

Possible failures of Java code core dump JVM Tuning the application server is recommended as opposed to just sticking with the default values assigned during an application server install. If the heap size is not managed or tuned, you may see the symptoms of poor memory management which can vary from intermittent performance problems to periodic failure and automatic restarts of the JVM which may not generate a core dump or error.

What we can do is set JVM arguments to ensure that Java core dumps are executed when the JVM crashes. A Java core dump is similar to a Linux core dump, which contains the processes and state of the OS system; however, a Java core dump only contains the processes and state of the JVM itself. A JVM may crash due to hung threads or other internal JVM issues; it could be faulty code, that is, a bug, or many other scenarios like deadlocked code. A Java core dump is essentially a set of Java stack traces at the moment the error occurs, or if a core dump is manually issued. We cannot cover all the scenarios which can cause a JVM crash, but we can show you some configurations to help you catch debug information that you can use in your investigations to find the root cause of a JVM crash. If we set the JVM to core dump, we will get a core dump file that we can review. If the JVM crashed because it did not have enough memory, the core dump would say so. It is important that every administrator knows how to use settings and debug the resulting core dump file. First, we will look at how to generate a Java core dump, and then we will look at how to analyze core dumps.

How to generate Java core dump files

Requesting a Java core dump using Jython

There are several ways to generate core dumps. First, we will create a simple Jython script that we can run to generate Java core dump information.
Create a file on your Linux system called and paste in the
the following code:

jvmObject = AdminControl.completeObjectName("type=JVM,process=s
erver1,*" )
AdminControl.invoke(jvmObject, "dumpThreads" )
<was_profile_root>/ -lang jython –f <path_to_file>/

Requesting a heap dump using JythonJV

By changing the script to the following, we can get the heap dump instead:

jvmObject = AdminControl.completeObjectName("type=JVM,process=serv
er1,*" )
AdminControl.invoke(jvmObject, "generateHeapDump" )

Requesting with kill -3 command

This signal is sent when a kill -3 command is issued against the JVM process. This signal typically does not end the JVM process. It generates a thread dump (java core) for diagnosing a potentially hung JVM process.

It is a good practice to create a bunch of Java Core files so you need to issue the command in a sequence of 60 seconds.

One Response

  1. How can we automate this process? I need to generate thread dumps when something is wrong with JVM to analyze.

Leave a Reply

Your email address will not be published. Required fields are marked *

More Posts

In the dynamic world of serverless computing, securing your AWS Lambda function is crucial. However, one often neglected area is the security of containerized applications in Amazon Elastic Container Registry...
Note: The following example demonstrates upgrading a Kubernetes cluster from version 1.23 to 1.24. Replace the version numbers according to your specific setup. To ensure a seamless upgrade, it’s crucial...
Get In Touch
ITGix provides you with expert consultancy and tailored DevOps services to accelerate your business growth.
Newsletter for
Tech Experts
Join 12,000+ business leaders and engineers who receive blogs, e-Books, and case studies on emerging technology.