WebSphere: Generating Heap Dump using Jython


WebSphere: Generating Heap Dump using Jython

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

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 threadDump.py and paste in the
the following code:

jvmObject = AdminControl.completeObjectName("type=JVM,process=s
erver1,*" )
AdminControl.invoke(jvmObject, "dumpThreads" )
<was_profile_root>/wsadmin.sh -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.

Leave a Reply

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

More Posts

What is Transit Gateway? Transit Gateway is a powerful service offered by Amazon Web Services (AWS) that simplifies network management, improves security, and reduces operational overhead and costs. It offers...
Today, we will explore how to access applications that are operating on Kubernetes. Specifically, we will delve into the functionality of Kubernetes services of type LoadBalancer, their use cases, and...
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.