This discussion is archived
7 Replies Latest reply: Jul 10, 2009 12:13 AM by 807557 RSS

JVM heap dump options??

807557 Newbie
Currently Being Moderated
Hello folks,


I am working with RTS2.1 on Linux and I am having difficulties finding the command line option
that would enable me to generate heap dump as part of an effort for application debugging.

I used to do that with -XX:+HeapDumpOnCtrlBreak command-line option.

Doesn't RTS have equivalent options?
When I tried the above options, RTS does not recognize it and refuse to start the JVM.

Best,

Jason
  • 1. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    HeapDumpOnCtrlBreak was a 1.4.2 option that was ported to 1.5.0_14. JRTS is based on the 1.5.0_04 VM and so does not support that option.

    JRTS does support jmap however so you can use the -heap:format=b option to generate a hprof format heap dump. You can then use the jhat tool from JDK6 or JDK7 to process the heap dump. You could also try VisualVM, or perhaps jconsole. See the JRTS "Tools, Tuning, and Troubleshooting Guide" for some additional info.

    HTH

    David Holmes
  • 2. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    Hello David,

    Thanks for timely response.
    After my post, I belatedly found the JRTS document and on my way to working with it.

    Best,

    Jason
  • 3. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    Hello David,

    I could use a little bit further direction with regard to the jmap;
    When I tried to get a heap dump of the little RTS test program via jmap, I am greeted with the following messages;
    Here is my shell script that started my test program;

    $RTS/bin/java -cp $CLASSPATH/rtqueue.jar -server -Xms64m -Xmx64m -XX:LargePageSizeInBytes=4m -XX:ImmortalSize=16m -XX:RTGCCriticalReservedBytes=12m -XX:+UseRTGC rtqueue.QueueTest_2 200 0 true

    ------------------------------------------------------------------------------
    #
    # output from jmap -heap:format=b 18202
    #
    Attaching to process ID 18202, please wait...
    Debugger attached successfully.
    Client compiler detected.
    JVM version is 1.5.0_16-b11
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at sun.jvm.hotspot.oops.ObjectHeap.newOop(ObjectHeap.java:342)
    at sun.jvm.hotspot.utilities.HashtableEntry.literal(HashtableEntry.java:36)
    at sun.jvm.hotspot.memory.DictionaryEntry.klass(DictionaryEntry.java:49)
    at sun.jvm.hotspot.memory.Dictionary.classesDo(Dictionary.java:49)
    at sun.jvm.hotspot.memory.SystemDictionary.classesDo(SystemDictionary.java:150)
    at sun.jvm.hotspot.memory.SystemDictionary.allClassesDo(SystemDictionary.java:143)
    at sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeClasses(HeapHprofBinWriter.java:840)
    at sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:381)
    at sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:133)
    at sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:143)
    at sun.jvm.hotspot.tools.JMap.run(JMap.java:71)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:204)
    at sun.jvm.hotspot.tools.JMap.main(JMap.java:126)
    Caused by: java.lang.RuntimeException: field "_itable_len" not found in type instanceKlass
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:166)
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:173)
    at sun.jvm.hotspot.types.basic.BasicType.getField(BasicType.java:177)
    at sun.jvm.hotspot.types.basic.BasicType.getCIntegerField(BasicType.java:240)
    at sun.jvm.hotspot.oops.InstanceKlass.initialize(InstanceKlass.java:72)
    at sun.jvm.hotspot.oops.InstanceKlass.access$000(InstanceKlass.java:20)
    at sun.jvm.hotspot.oops.InstanceKlass$1.update(InstanceKlass.java:24)
    at sun.jvm.hotspot.runtime.VM.registerVMInitializedObserver(VM.java:306)
    at sun.jvm.hotspot.oops.InstanceKlass.<clinit>(InstanceKlass.java:22)
    ... 13 more


    #---------------------------------------------------------------------------
    #Output from the jmap -heap pid 18226
    #
    Attaching to process ID 18226, please wait...
    Debugger attached successfully.
    Client compiler detected.
    JVM version is 1.5.0_16-b11

    Mark Sweep Compact GC

    Heap Configuration:
    MinHeapFreeRatio = 40
    MaxHeapFreeRatio = 70
    MaxHeapSize = 67108864 (64.0MB)
    NewSize = 655360 (0.625MB)
    MaxNewSize = 4294967295 (4095.9999990463257MB)
    OldSize = 1441792 (1.375MB)
    NewRatio = 12
    SurvivorRatio = 8
    PermSize = 67108864 (64.0MB)
    MaxPermSize = 67108864 (64.0MB)

    Heap Usage:
    Exception in thread "main" java.lang.RuntimeException: unknown heap type : class sun.jvm.hotspot.gc_interface.CollectedHeap
    at sun.jvm.hotspot.tools.HeapSummary.run(HeapSummary.java:105)
    at sun.jvm.hotspot.tools.JMap.run(JMap.java:85)
    at sun.jvm.hotspot.tools.Tool.start(Tool.java:204)
    at sun.jvm.hotspot.tools.JMap.main(JMap.java:126)


    I suspect that the test application has a memory leak and I would like to look at the heap dump.

    TIA,

    Jason
  • 4. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    I would need some more pointers on jamp
  • 5. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    That's strange, the exception you are seeing relates to a bug that was fixed prior to 2.1 being released. ??? I tried a simple example on linux and Solaris and it worked as expected.

    You must use the jmap command from the Java RTS distribution, but based on the output it appears that you did do that. And your use of the jmap command is correct (see the jmap manpage in the JRTS distribution for the only additional information).

    Sorry I don't know what else to suggest here with regards to jmap.

    David Holmes
  • 6. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    Hmmm. I guess it's time for me to see if I have the correct version of the RTS first.
    I will contact my Java Licensee business manager.

    Thanks David.
  • 7. Re: JVM heap dump options??
    807557 Newbie
    Currently Being Moderated
    Please do "java -version" and see if it corresponds to:

    java version "1.5.0_16"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16_Java-RTS-2.1_fcs-b11_RTSJ-1.0.2)
    Java Real-Time System HotSpot(TM) Client VM (build 1.5.0_16-b11, mixed mode)

    David