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

incorrect amount of committed memory if -Xms specified

XMLWordPrintable

    • tiger
    • generic
    • generic
    • Verified



      Name: viR10068 Date: 09/08/2003


      The spec for the committed memory says:
      "committed
             represents the amount of memory (in bytes) that is guaranteed
             to be available for use by the Java virtual machine. The amount
             of committed memory may change over time (increase or decrease).
             It is guaranteed to be greater than or equal to initSize if
             initSize is defined."

      But if the initial Java heap size was set (by -Xms options) the amount of
      committed memory returned by getCommitted() is less than the initSize.

      So the RI or spec should be fixed.

      This bug causes the failure of the JCK tests:
      api/java_lang/management/MemoryMBean/index.html#getMemUsage[getMemUsage0001]
      api/java_lang/management/MemoryMBean/index.html#getMemUsage[getMemUsage0101]
      api/java_lang/management/MemoryUsage/index.html#MemoryUsage[MemoryUsage0004]

      Source code:
      =========================== musage.java ====================================

      import java.io.PrintStream;
      import java.lang.management.*;
      import javax.management.*;

      public class musage {

          public static int run(String argv[], PrintStream out) {
              musage muse = new musage();

              System.out.println("Exit code for getMemUsage0001 is " + muse.getMemUsage0001());
              return 0;
          }

          public static void main(String argv[]) {
              System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
          }


          private static int check_MemoryUsage_object(MemoryUsage mu) {
              if (mu.getUsed() < 0) {
                  System.out.println("The amount of used memory in bytes is negative");
                  return 2;
              }
              if (mu.getCommitted() < 0) {
                  System.out.println("The amount of committed memory in bytes is negative");
                  return 2;
              }
              if (mu.getCommitted() < mu.getInit()) {
                  System.out.println(mu.getCommitted() + ":" + mu.getInit() + " committed <
      initSize");
                  return 2;
              }
              System.out.println("OKAY");
              return 0;
          }

          public int getMemUsage0001() {
              MemoryMBean tob = ManagementFactory.getMemoryMBean();
              MemoryUsage mu = tob.getHeapMemoryUsage();
              return check_MemoryUsage_object(mu);
          }
      }
      =======================================================================
      Execution log:
      % jdk1.5.0-b18/solaris-sparc/bin/javac musage.java && jdk1.5.0-b18/solaris-sparc/bin/java
      -showversion -Xfuture -Xms128M -Xmx128M musage
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b18)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b18, mixed mode)

      133824512:134217728 committed < initSize
      Exit code for getMemUsage0001 is 2
      %

      ======================================================================

            mchung Mandy Chung
            vivsunw Viv Viv (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: