Friday, March 11, 2016

How to take heap dumps in Linux

To Identify what is holding the memory (why GC is not releasing the memory, There could be memory leak some where) take heap dump when this condition arises and fix the OutOfMemory situation.

Capture heap dump using jmap:

Use the following command to generate a heap dump when the server is at a critical memory level (reaching the limit for an out of memory). This should typically generate a very large file called heap.bin.

Syntax: /Java/jdk/bin/jmap -heap:format=b <pid>
Eg: jmap -heap:format=b 19096

<pid> is the process number of the WebLogic server instance


Capture heap dump when OOM occurs:

Enable flag "-XX:+HeapDumpOnOutOfMemoryError" in server startup script which will generate heapdump when OOM happens.

Eg: JAVA_OPTIONS="-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:/local/apps/oracle/middleware/user_domains/test/bin/gc.txt -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/local/apps/oracle/middleware/user_domains/test/bin " ${JAVA_OPTIONS}"

Review the heap dump to under the objects that are occupying the memory and the frequency that they get generated until they actually reach JVM memory threshold.

1 comment:

  1. Nice and good blog.I have suggested to my friends to go through this blog. Thanks for sharing this useful information. If you want to learn Linux course in online, please visit below site.
    Linux Online Training
    linux online course
    Linux Online Training in Hyderabad
    Linux Online Training in Bangalore
    Linux Online Training in Chennai

    ReplyDelete