Tuesday, November 17, 2009

Generating Heapdump On JDK5(v16+)

Teammates and I are doing one thing to get our life a little bit easier--Generating Heapdump On JDK5(V16+); P.S. unfortunately you could not using this way if you are using lower version of JDK5, like JDK1.5.0_11... A bug reported here for your information, you have to use JDK5(V16+): http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6454676

Thanks Andy and Adams' great idea and Support!!
0. download PsTools and SendSignal and gawk into your target machine as PS_TOOLS_HOME
1. Add -XX:+HeapDumpOnCtrlBreak in your JVM arguments
2. Using SendSignal to simulate the Ctl+Break signal to the service

here is the HeapGen.bat file, hope this helps you too:

 @echo off  
 rem -------------------------------------------------------------------------  
 rem Invoking Remote JVM to do Heap Dump Script for Win32  
 rem 1. Please replace your directory of PsTools  
 rem 2. Please set IP before execute it  
 rem -------------------------------------------------------------------------  
 set PS_TOOLS_HOME=D:\\PsTools  
 set JVM_IP=10.279.33.33  
 set HPROF_HOME=D:\abc\efg\bin  
 echo ===================================================================================  
 echo .  
 echo Your Directory of PsTools is %PS_TOOLS_HOME%  
 echo .  
 echo The Remotely Controlled Machine is %JVM_IP%  
 echo .  
 echo Heap dump is created in a file in the working  
 echo directory of the VM namely %HPROF_HOME%  
 echo .  
 echo =================================================================================== 
 echo .  
 %PS_TOOLS_HOME%\pslist \\%JVM_IP% -u "${Domainname}\${yourusername}" -p "${yourpassword}" -e java | %PS_TOOLS_HOME%\gawk "{if($1 ~ /java/) system(\" %PS_TOOLS_HOME%\\psexec \\\\%JVM_IP% -d -c %PS_TOOLS_HOME%\\SendSignal \" $2)}"  
 echo .  
 echo ===================================================  
 echo .  
 echo Heap Dump file has been created  
 echo .  
 echo ===================================================  
 echo .   

No comments:

Post a Comment