开发者

jdk1.6 JMAP.EXE: Remote thread failed for unknown reason

I get this error when using the following batch file to take a core dump of a Java service running in a Windows console shell:

The parent directory name of this script is: MyDIR
Install dir is: C::\InstallDIR    
The process id of window called MyDIR is 520
Taking core dump... please wait...
C::\InstallDIR\Javasoft\bin\jmap.exe -dump:file=heap.bin 520
Dumping heap to C:\InstallDIR\MyDIR\heap.bin ...
Exception in threa开发者_如何学JAVAd "main" java.lang.InternalError: Remote thread failed for 
  unknown reason
        at sun.tools.attach.WindowsVirtualMachine.enqueue(Native Method)
        at sun.tools.attach.WindowsVirtualMachine.execute(WindowsVirtualMachine.java:78)
        at sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:195)
        at sun.tools.attach.HotSpotVirtualMachine.dumpHeap(HotSpotVirtualMachine.java:162)
        at sun.tools.jmap.JMap.dump(JMap.java:224)
        at sun.tools.jmap.JMap.main(JMap.java:122)
Press any key to continue . . .

And here is the script (-XX:OnError="script.bat") :

@echo off
setlocal
set PATH=%PATH%;C:\InstallDIR\Javasoft\jre\bin\server
for /F "tokens=2,3,4,5,6,7 delims=\" %%i in ('cd') do (
  set i=%%i
  set j=%%j
  set k=%%k
  set l=%%l
  set m=%%m
  set n=%%n
)
set HOME=%i%
if not "%i%" == "" (set SITE=%i%
) else (goto end:)
if not "%j%" == "" (set SITE=%j%
) else (goto end:)
if not "%k%" == "" (set SITE=%k%
) else (goto end:)
if not "%l%" == "" (set SITE=%l%
) else (goto end:)
if not "%m%" == "" (set SITE=%m%
) else (goto end:)
if not "%n%" == "" (set SITE=%n%
) else (goto end:)
:end
echo The parent directory name of this script is: %SITE%
echo Install dir is: %HOMEDRIVE%:\%HOME%
echo.

:: kill process using window TITLE to find PID
FOR /F "tokens=2" %%I in ('TASKLIST /NH /FI "WINDOWTITLE eq %SITE%"' ) DO SET PID=%%I
ECHO The process id of window called %SITE% is %PID%
ECHO Taking core dump... please wait...
%HOMEDRIVE%\%HOME%\Javasoft\bin\jmap.exe -dump:format=b,file=heap.bin %PID%
ECHO Killing JVM %PID%...
TASKKILL /PID %PID%
:: then , restart server
.\startServer.bat    
ping -n 12 127.0.0.1>nul
if ERRORLEVEL == 0 (
  exit
) else (
  pause
)

I can run jconsole.exe , attach to the process and dump the core easily. Why isn't this as easy from the command line? I know that the linux version of JMap has more options and capabilities. Is this what I am running into here: a situation where the windows version of JMap just isn't able to do this simple thing?


The -XX:OnError handler is called for fatal jvm errors. when that happens you probably won't be able to start a new thread to dump the heap. (That's what jmap does.)

However, you can probably accomplish what you want by passing
-X:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath=path.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜