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

"jmap -heap" (ServiceabilityAgent HeapSummary) uses excessive precision/scientific notation for printing.

    Details

    • Type: Bug
    • Status: Open
    • Priority: P5
    • Resolution: Unresolved
    • Affects Version/s: hs25, 7, 8
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      If I run "jmap -heap" on a running process (or a core file), I get output like:

          analemma $ $Deployed/JDK-7/bin/jmap -heap 12756
          Attaching to process ID 12756, please wait...
          Debugger attached successfully.
          Server compiler detected.
          JVM version is 11.0-b07

          using thread-local object allocation.
          Parallel GC with 2 thread(s)

          Heap Configuration:
             MinHeapFreeRatio = 40
             MaxHeapFreeRatio = 70
             MaxHeapSize = 536870912 (512.0MB)
             NewSize = 2228224 (2.125MB)
             MaxNewSize = 4294901760 (4095.9375MB)
             OldSize = 4194304 (4.0MB)
             NewRatio = 2
             SurvivorRatio = 8
             PermSize = 16777216 (16.0MB)
             MaxPermSize = 67108864 (64.0MB)

          Heap Usage:
          PS Young Generation
          Eden Space:
             capacity = 9437184 (9.0MB)
             used = 188760 (0.18001556396484375MB)
             free = 9248424 (8.819984436035156MB)
             2.0001729329427085% used
          From Space:
             capacity = 1572864 (1.5MB)
             used = 0 (0.0MB)
             free = 1572864 (1.5MB)
             0.0% used
          To Space:
             capacity = 1572864 (1.5MB)
             used = 0 (0.0MB)
             free = 1572864 (1.5MB)
             0.0% used
          PS Old Generation
             capacity = 25165824 (24.0MB)
             used = 0 (0.0MB)
             free = 25165824 (24.0MB)
             0.0% used
          PS Perm Generation
             capacity = 16777216 (16.0MB)
             used = 1642424 (1.5663375854492188MB)
             free = 15134792 (14.433662414550781MB)
             9.789609909057617% used

      where Java double printing is used to print out the sizes in megabytes. Often that works pretty well, but for some numbers, e.g., "15134792 (14.433662414550781MB)", the printing to 15 decimal places is bogus. In that case you would talking about fractions of bytes down to nano-bytes, if those existed.

      The code is in hotspot/agent/src/share/classes/sun/jvm/hotspot/tools/HeapSummary.java, in printValMB(String, long). Rather than just calling System.out.println for the value and the mb, I think you'll have to use printf with some reasonable number of decimal places for the mb. Since you've already printed the real value, I think 3 decimal places would be enough, but anything over 6 decimal places is overkill for printing megabytes.

      (I'll let you decide if the "% used" values should have some restricted number of decimal places. :-)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                pbk Peter Kessler
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Imported:
                  Indexed: