Reputation: 177
How can I get aheap dump from a remote JVM which runs on linux with WL application server?
When I run locally on a windows machine I know how to get a dump. But, how do I get a dump from the user acceptance test server? Thanks in advance.
Upvotes: 11
Views: 17810
Reputation: 20386
You can use JMX to connect to the remote application server (it should be enabled in advance) and use the HotSpotDiagnostic MBean which allows taking a heap dump.
You can use JConsole or VisualVM for invoking the MBean operation.
This post by Mike Haller describes how to use this method with JVisualVM.
Upvotes: 12
Reputation: 15723
I've used Visual VM successfully for thread dumps and heap dumps, however, you don't list your JAVA version?
JAVA Visual VM is no longer shipped with JAVA, but can still be downloaded here and it's still being maintained. They just did a new minor release: October 19, 2021: VisualVM 2.1.1 Released.
VisualVM has also been distributed in Oracle JDK 6~8 as Java VisualVM. It has been discontinued in Oracle JDK 9.
Here are steps for connecting to the VM from Dzone, VisualVM: Monitoring Remote JVM Over SSH (JMX Or Not)
For other alternatives, the Baeldung JAVA site, which has great information and tutorials, has A Guide to Java Profilers.
Upvotes: 1
Reputation: 13015
There are three steps:
ssh <your_user_name>@<remote_ip>
jmap -dump:format=b,file=<your_file_name> <your_jvm_pid>
jhat -J-Xmx512m <your_file_name>
jhat -port 7401 <your_file_name>
I write a blog to help analyze performance issue: Performance Optimization
Upvotes: 1
Reputation: 16394
Since its a *-nix system, and if you have the necessary privieleges, then it would be easy to connect to using SSH protocol:
Connect to the remote machine:
ssh user@remote-machine-ip-address
Enter the user password once prompted for it (it should be the one for the user on the remote machine and not your current system user).
Generate your heap dump using the jmap
utility (JDK binaries path should be availble into your system PATH variable or use a full path to it):
jmap -dump:format=b,file=cheap.bin <pid>
Upvotes: 2