Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8137081

Should have a way to generate a live histogram dump on OutOfMemoryError

    XMLWordPrintable

    Details

    • Subcomponent:
      svc

      Description

      HotSpot has a -XX:+HeapDumpOnOutOfMemoryError option for generating full heap dump on OutOfMemoryError. For analyzing memory leaks this is not very convenient because for instance:
      - the dump is a full heap dump which can be very large (as the heap is full at generation time) and can break more stuff on production systems if this fills the disk
      - as the dump may be very large, it may be impossible to open it for reading with usual tools (Eclipse MAT, jvisualvm...)
      - this may cause security problems: user data stored on disk, then sent to oracle support (difficult), then full user data on oracle site (which the customer probably does not want)
      ...etc

      For analyzing/debugging memory leaks, live histogram dump (jmap -histo:live) is however a very convenient way to start with. Usually the abnormal high number of instances in a class gives a very good hint to find the root cause of the memory leak. This also eliminates a lot of problems:
      - very small data
      - easy opening/reading
      - easy transfert to support teams

      So the request is to have a mean to ask for a jmap -histo:live equivalent dump on OutOfMemoryError. This could for instance be an additional option to -XX:+HeapDumpOnOutOfMemoryError (as is -XX:HeapDumpPath option) like -XX:DumpLiveHisto.

      The -XX:HeapDumpPath could also work with this additional new option to specify the path of the histo live dump.

      Note that we tried to workaround this by using the -XX:OnOutOfMemoryError with a jmap command like: -XX:OnOutOfMemoryError="jmap -histo:live %p"

      But this did not work as we got:

      --------------
      # java.lang.OutOfMemoryError: Java heap space
      # -XX:OnOutOfMemoryError="jmap -histo:live %p"
      # Executing /bin/sh -c "jmap -histo:live 28242"...
      28242: Unable to open socket file: target process not responding or HotSpot VM not loaded
      The -F option can be used when the target process is not responding
      --------------

      But the -F option is not supported with the live option. Removing the live option and using -F was also not working. We suspect that the jmap anyway requires at this time some processing in the VM process which cannot happen due to out of memory or something like that.

      Anyway, this would be better to have a dedicated option for that. (However if you know why the workaround in not working, we are interested to know how to do this, please do not hesitate to contact us).

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Dates

              Created:
              Updated: