We may sometimes encounter situations where javaagent cannot be used temporarily, such as a web app restart on a server that is too time consuming, which we can consider using the following method.
With Dumpclass, the Dumpclass is currently poorly performing on windows and is recommended for use on Linux
Dumpclass Project Address
Https://github.com/hengyunabc/dumpclass
Http://central.maven.org/maven2/io/github/hengyunabc/dumpclass/0.0.2/dumpclass-0.0.2.jar
You need to configure the path before using Dumpclass
Edit ~/.BASHRC
sudo gedit ~/.BASHRC
In
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Post-add
Export Classpath=.:${java_home}/lib:${jre_home}/lib:${java_home}/lib/tools.jar:${java_home}/lib/dt.jar:${java_ Home}/lib/sa-jdi.jar
Make environment variables effective
SOURCE ~/.BASHRC
How to use
Use JPS to view running Java processes first
[Email protected]:~$ jps4965 Jps2361 org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar2605 AppServer
We need to dump the process for appserver, the process ID to write down
Class after which the employee ends in the dumpappserver process
Java-jar Dumpclass-0.0.2.jar 2605 *employee out--classloaderprefix
2605 for the dump process, *employee represents the class terminated with the employee, out is the exported directory
The first dump may encounter problems that prompt "Can ' t attach to the process"
Cd/etc/sysctl.d
There is a file named "10-ptrace.conf" in this directory,
sudo nano 10-ptrace.conf
Open the file with Superuser privileges and change the inside line Kernel.yama.ptrace_scope = 1 to Kernel.yama.ptrace_scope = 0
Save and exit and restart the system.
(If you wonder why you should change it, take a good look at the notes in that file)
Java Reverse Base export class two in memory