Hi,

Jay SenSharma

Jay SenSharma

Note: Jmap will not work for Any kind of Windows Service so please refer to the following article to know how to generate HeapDump in case of Windows Services : How to Generate HeapDump in case of Windows Service ?

Here is a Simple Demonstration of using JMap to Generate the Binary heap Dump…Which we will analyze later using Jhat tool. These tools are very common and freely available for Download porpose. But from Sun JDK 1.6 Onwards it is by default available inside “<JAVA_HOME>bin” directory.

What is Jmap And Why Not Jhat?
Jmap is much better than Jhat utility because to start with Jmap utility u need not to apply any JAVA_OPTION on the WebLogic Server … you can directly start with any WebLogic Server which is Running on Sun JDK …. All u need to do is …Just find the Process ID of that WLS Server…thats all.

Jmap generates the Heap Dump Much faster than Jhat.

Jhat HeapDumps sometimes are seen as currupted file…But jmap is more reliable and generates the correct Heap Dump file. (correct heap dump generation percentage wise it is better than Jhat)

Step1). Start a Weblogic Server instance normally on your Local Machine and then find the Process ID (PID).

Step2). If you are using Unix Based Operating System then u can find out the Process ID (PID) by running the following Command:

ps -ef | grep java

If you are using Windows then follow the below Steps to find out the Process ID (PID):

a) Press “Ctrl+Alt+Del” 2 buttons together.
b) Press the “Task Manager” Button
c) Click on “Processes” Tab.
d) Now Select the Menu Item “View” — > “Select Columns”
e) Check the “PID (Process Identifier)” Check box as well…
f) Now u can see the Process Id of “java.exe” in the “Processes” Tab.

Finding WLS Process ID in WINDOWS

Finding WLS Process ID in WINDOWS

Step3). Start the “JMap” tool from “<JAVA_HOME>bin” directory as following:

C:bea103jdk160_05bin>jmap -dump:format=b,file=heapJMap.bin 7540

Note: use  -J-d64 jvm option if your JVM is 64 Bit Jvm jmap    -J-d64 -heap     pid”

Heap Dump Generation Using Jmap

Heap Dump Generation Using Jmap

Step4). To Read the Binary Heap Dump File … Jhat is one of the Best Tool… Please run the following command to inoke the “jhat” tool Http Server by passing the Heap Dump File name…

C:bea103jdk160_05bin>jhat -J-mx1024m heapJMap.bin

Using Jhat HttpServer to read the Jmap Generated HeapDump

Using Jhat HttpServer to read the Jmap Generated HeapDump

Step5). Now open a Web Browser with the following URL: “http://localhost:7000”
and refer to Post:  heap-dump-using-jhat-for-weblogic-server-heap-analysis/

Jhat Non Product Instance Counter

Jhat Non Product Instance Counter

Step6). U can use  different options available as part of “jmap” to analyze the Binary heap Dump like

To See the Heap Histogram u can do the following:

You can use some other “Jmap” options as well:

JMap Histogram Analysis

JMap Histogram Analysis

-finalizerinfo
Prints information on objects awaiting finalization.
-heap
Prints a heap summary. GC algorithm used, heap configuration and generation wise heap usage are printed.
-permstat
Prints class loader wise statistics of permanent generation of Java heap. For each class loader, its name, liveness, address, parent class loader, and the number and size of classes it has loaded are printed. In addition, the number and size of interned Strings are printed.

.
.
Thanks
Jay SenSharma

If you enjoyed this post, please considerleaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.