Websphere - generating heap dump using jython
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 the 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 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 which 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 which 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.
Howto 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 which we can run to generate Java core dump information.
1. Create a file on your Linux system called threadDump.py and paste in the
jvmObject = AdminControl.completeObjectName("type=JVM,process=s
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
AdminControl.invoke(jvmObject, "generateHeapDump" )
The result of running this Jython script is shown in the screenshot below:
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 (javacore) for diagnosing a potentially hung JVM process.
It is a good pratice to create a bunch of javacore files so you need to issue the command in sequence of 60 seconds.