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

(bf) Ridiculous direct-memory limits not handled correctly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 5.0
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood
    • CPU:
      generic
    • OS:
      generic

      Description

      The VM.maxDirectMemory method doesn't behave properly on negative numbers,
      which can be passed in from HotSpot via the sun.nio.MaxDirectMemorySize system
      property when a ridiculously large value is specified on the command line.
      Rather than taking the hardwired default value of 64MB it should instead take
      the value of Runtime.getRuntime().maxMemory(). This difference is more
      noticeable now that we have ergonomic GC sizing.

      % cat MDM.java

      public class MDM {

          public static void main(String[] args) {
              long mm = Runtime.getRuntime().maxMemory();
              long mdm = sun.misc.VM.maxDirectMemory();
              if (mm != mdm)
                  throw new Error("maxMemory = " + mm
                                  + ", maxDirectMemory = " + mdm);
          }

      }
      % /local/jdk/1.5/bin/java -version
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b50)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b50, mixed mode)
      % /local/jdk/1.5/bin/java -XX:MaxDirectMemorySize=42g MDM
      Exception in thread "main" java.lang.Error: maxMemory = 66650112, maxDirectMemory = 67108864
              at MDM.main(MDM.java:8)
      %

      -- ###@###.### 2004/5/14

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              mr Mark Reinhold
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Imported:
                Indexed: