Unable to create heap dump due to ReadVirtual failed
Asked Answered
C

2

6

We have a JBoss application server running in Java 6 update 45. We are running into OutOfMemoryErrors that we have most likely introduced ourselves. We'd like to analyze those and want to create a heap dump. This fails with the exception below.

Googling and searching stackoverflow has not helped me much, does anyone have an idea on how to get a heap dump from this machine?

Thanks!

Martin

The exception is:

C:\>"d:\Program Files\Java\bin\"jmap -F "-dump:format=b,file=D:\heapdumps\20130620_085902_heap.dump" 1832
Attaching to process ID 1832, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.45-b01
Dumping heap to D:\heapdumps\20130620_085902_heap.dump ...
Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at sun.tools.jmap.JMap.runTool(JMap.java:179)
        at sun.tools.jmap.JMap.main(JMap.java:110)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: Windbg Error: ReadVirtual failed!
        at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readBytesFromProcess0(Native Method)
        at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readBytesFromProcess(WindbgDebuggerLocal.java:485)
        at sun.jvm.hotspot.debugger.DebuggerBase$Fetcher.fetchPage(DebuggerBase.java:76)
        at sun.jvm.hotspot.debugger.PageCache.getPage(PageCache.java:178)
        at sun.jvm.hotspot.debugger.PageCache.getInt(PageCache.java:96)
        at sun.jvm.hotspot.debugger.DebuggerBase.readCInteger(DebuggerBase.java:355)
        at sun.jvm.hotspot.debugger.DebuggerBase.readCompOopAddressValue(DebuggerBase.java:459)
        at sun.jvm.hotspot.debugger.windbg.WindbgDebuggerLocal.readCompOopHandle(WindbgDebuggerLocal.java:332)
        at sun.jvm.hotspot.debugger.windbg.WindbgAddress.getCompOopHandleAt(WindbgAddress.java:122)
        at sun.jvm.hotspot.oops.Oop.getKlassForOopHandle(Oop.java:235)
        at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:378)
        at sun.jvm.hotspot.oops.ObjectHeap.iterateLiveRegions(ObjectHeap.java:464)
        at sun.jvm.hotspot.oops.ObjectHeap.iterate(ObjectHeap.java:249)
        at sun.jvm.hotspot.utilities.AbstractHeapGraphWriter.write(AbstractHeapGraphWriter.java:51)
        at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:416)
        at sun.jvm.hotspot.tools.HeapDumper.run(HeapDumper.java:56)
        at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
        at sun.jvm.hotspot.tools.HeapDumper.main(HeapDumper.java:77)
        ... 6 more
Camerlengo answered 20/6, 2013 at 7:55 Comment(3)
This bug seems related, however it has been marked as fixed...Vu
Yeah, that's one of the posts that I found in Googling, but it should not be a problem in a 6u45 JDK...Camerlengo
Maybe you could try, if at all possible, to reproduce with OpenJDK 6 and open a bug to them if it is reproducible?Vu
C
0

Hmm, found the answer on another website and this does seem to work. We are now asking the JVM to make a heap dump when it encounters an OutOfMemoryError with the following options:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./java_pid<pid>.hprof

As found on:

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Camerlengo answered 15/7, 2013 at 13:53 Comment(1)
Alright, this works fine if you have access to the startup parameters and if the process is not running yet. However, I am also looking for a "real" solution to get rid of the Exception. Unfortunately, the software is shipped with on an old JRE version, which is why updating JRE does not help. Did you/ anybody find another way?Wylma
P
1

Please check below points,

  1. Run the command console as Administrator
  2. version of JDK (for jmap command) and JRE (Java app run environment) should be same.
  3. If got exception with JDK/JRE 7try the same with JDK/JRE 8

Actually I faced some issue in jmap with JDK 7, but when i moved to JDK 8, I were able to successfully generate the heap dump using below command

jmap -dump:file=d:\heapdump\myHeapDump.hprof -F

Piemonte answered 21/12, 2016 at 7:18 Comment(0)
C
0

Hmm, found the answer on another website and this does seem to work. We are now asking the JVM to make a heap dump when it encounters an OutOfMemoryError with the following options:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=./java_pid<pid>.hprof

As found on:

http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

Camerlengo answered 15/7, 2013 at 13:53 Comment(1)
Alright, this works fine if you have access to the startup parameters and if the process is not running yet. However, I am also looking for a "real" solution to get rid of the Exception. Unfortunately, the software is shipped with on an old JRE version, which is why updating JRE does not help. Did you/ anybody find another way?Wylma

© 2022 - 2024 — McMap. All rights reserved.