Heap Dump In weblogic Admin
jmap command is used to generate heap dump if your using Sun JDK
jrcmd command is used to generate heap dump if your using
Jrocket.
Don't generate heap dump multiple times as it causes your
application performance degradation as generating heap dump will take at
least 15 to 30 minutes and generated file size will be minimum 2 GB. And use
Eclipse mat only to analyze it. IBM heap analyzer will not help you in this
case due to IBM heap analyzer supports hprof formated files only to my
knowledge
*********************************************************************************
Heap dump - Collection of objects that are in memory (JVM)
Thread dump - Shows what each thread in a process is doing at a given point in time along with the stack trace.
Core dump - O/S level dump file which has O/S level info in addition to the heap dump.
Heap dump - is useful to analyse OOM situations.
Thread dump - To troubleshoot slow running of your application.
Core dump - When your JVM has crashed abruptly. To find details about native calls and so on.
jmap -heap:live,format=b,file=filename pid
jrcmd pid hprofdump filename=name_of_dump_file
========================================================================
A thread dump is a dump of the stacks of all live threads. Thus useful for analyzing what an app is up to at some point in time, and if done at intervals handy in diagnosing some kinds of 'execution' problems (e.g. thread deadlock).
A heap dump is a dump of the state of the Java heap memory. Thus useful for analyzing what use of memory an app is making at some point in time so handy in diagnosing some memory issues, and if done at intervals handy in diagnosing memory leaks.
===================================================================
Heapdump can be taken in number of ways:
Via Java VM parameters:
-XX:+HeapDumpOnOutOfMemoryError writes heap dump on OutOfMemoryError (recommended)
-XX:+HeapDumpOnCtrlBreak writes heap dump together with thread dump on CTRL+BREAK
Using JRockit:
-jrcmd pid hprofdump filename=name_of_dump_file
Using Jmap:
-jmap -heap:format=b pid
Note: use -J-d64 jvm option if your JVM is 64 Bit Jvm “jmap -J-d64 -heap pid”
You can also manually generate a heap dump with tool VisualVM.
Using HPROF:
You can use HPROF: Heap and CPU Profiling Agent.
A complete dump of the current live objects in the heap can be obtained with:
-java -agentlib:hprof=heap=dump,format=b -jar application
This will automatically dump heap when java application is terminated. You can also force heap dump by sending QUIT signal to java process with kill -QUIT pid command.
Analysing Heapdump file using Jhat
You can use jhat (Java Heap Analysis Tool) to read the generated file:
- jhat [ options ]
The jhat command parses a java heap dump file and launches a webserver. jhat enables you to browse heap dumps using your favorite webbrowser.
Note that you should have a hprof binary format output to be able to parse it with jhat. You can useformat=b option to generate the dump in this format.
*****************************************************************************
Command to get Heap Dump on UNIX Platform:
Step1: Get the process ID of the server for which you are taking heap dump using below command
Heapdump can be taken in number of ways:
Via Java VM parameters:
-XX:+HeapDumpOnOutOfMemoryError writes heap dump on OutOfMemoryError (recommended)
-XX:+HeapDumpOnCtrlBreak writes heap dump together with thread dump on CTRL+BREAK
Using JRockit:
-jrcmd pid hprofdump filename=name_of_dump_file
Using Jmap:
-jmap -heap:format=b pid
Note: use -J-d64 jvm option if your JVM is 64 Bit Jvm “jmap -J-d64 -heap pid”
You can also manually generate a heap dump with tool VisualVM.
Using HPROF:
You can use HPROF: Heap and CPU Profiling Agent.
A complete dump of the current live objects in the heap can be obtained with:
-java -agentlib:hprof=heap=dump,format=b -jar application
This will automatically dump heap when java application is terminated. You can also force heap dump by sending QUIT signal to java process with kill -QUIT pid command.
Analysing Heapdump file using Jhat
You can use jhat (Java Heap Analysis Tool) to read the generated file:
- jhat [ options ]
The jhat command parses a java heap dump file and launches a webserver. jhat enables you to browse heap dumps using your favorite webbrowser.
Note that you should have a hprof binary format output to be able to parse it with jhat. You can useformat=b option to generate the dump in this format.
*****************************************************************************
Command to get Heap Dump on UNIX Platform:
Step1: Get the process ID of the server for which you are taking heap dump using below command
ps -ef | grep
"server name"
Step2: Set PATH &
CLASSPATH as below
export PATH=$PATH:
export
CLASSPATH=$CLASSPATH:
Step3: Run below command to take Heap Dump
jmap -heap:format=b
It will generate a file named "heap.bin" in the path where you ran the command.
EX:
./jmap -dump:format=b,file=heapJMap.bin 5549
./jmap -heap:format=b 7611
jmap -heap:format=b
It will generate a file named "heap.bin" in the path where you ran the command.
EX:
./jmap -dump:format=b,file=heapJMap.bin 5549
./jmap -heap:format=b 7611
No comments:
Post a Comment