Weblogic Heap Dump in Brief

Overview:

In WebLogic, a heap dump is a snapshot of the memory heap of a Java Virtual Machine (JVM) at a specific point in time. It captures all the objects and data structures that are present in the JVM’s memory, including objects that are no longer in use but have not been garbage collected.

A heap dump can be useful in identifying memory leaks and analyzing memory usage of an application running on WebLogic. It can be generated manually or automatically when a specific condition, such as an out-of-memory error, occurs.

To generate a heap dump manually in WebLogic, you can use the following steps:

  1. Identify the JVM process ID (PID) of the WebLogic server using the command ps -ef | grep java.
  2. Connect to the JVM using a tool like JConsole or VisualVM.
  3. Select the process with the corresponding PID and go to the Memory tab.
  4. Click on the Heap Dump button to generate the dump file.

Heap Dump using WLST

Heap dumps can be generated using WLST commands in WebLogic. Below is an example of how to generate a heap dump using WLST:

The below script will generate a heap dump file in the WebLogic server’s current working directory with the name “filename”. The second parameter “true” specifies that a live heap dump should be taken.

connect(username, password, url)
serverRuntime()
dumpHeap("filename", "true")

To generate a heap dump on demand when a certain condition is met, you can use the following script:

connect(username, password, url)
serverRuntime()
cd('ServerRuntimes/<ServerName>')
old_count = 0
while true:
    count = get('HeapFreeCurrent') / 1024 / 1024
    if count < 100 and count != old_count:
        filename = "heap_dump_{0}.hprof".format(count)
        dumpHeap(filename, 'true')
        old_count = count
    sleep(10)

This script will generate a heap dump file with the name “heap_dump_X.hprof” (where X is the current heap usage in MB) when the heap usage drops below 100 MB. The script will check the heap usage every 10 seconds.

Heap dump analysis using Eclipse Memory Analyzer Tool (MAT)

Eclipse Memory Analyzer Tool (MAT) is a powerful tool for analyzing heap dumps generated by Java applications, including WebLogic Server. It provides various features to help identify memory leaks, analyze object retention paths, and find the root cause of out of memory errors.

To analyze a heap dump using MAT, follow these steps:

  1. Generate a heap dump of the WebLogic Server process using either the JMX console or WLST scripting.
  2. Download and install the latest version of MAT from the Eclipse website.
  3. Launch MAT and open the heap dump file.
  4. Analyze the heap dump using various features provided by MAT, such as the histogram view, dominator tree, and object query.
  5. Identify potential memory leaks by analyzing object retention paths and looking for objects that are not being garbage collected.
  6. Use MAT to generate reports and visualizations to help identify and fix memory issues.

Overall, analyzing heap dumps using MAT can be an effective way to diagnose and fix memory-related issues in WebLogic Server applications.

Cheers!!!

About the author

Mohit Chaudhary

Hey there, I am IT enthusiast who is passionate about Middleware, DevOps, Cloud and much more.

View all posts

Leave a Reply

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