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

HotSpot actually needs more RAM than described in System Requirements

XMLWordPrintable

    • 1.0.1
    • x86
    • windows_nt



      Name: dkC59003 Date: 07/22/99



      The "System Requirements" section in README for HotSpot demands that
      Win32 computer should have at leats 48Mb of RAM installed (64Mb is
      recommended for Sparc/Solaris). However, HotSpot 1.0.1 for win32 seems
      to actually need more than 64Mb of RAM installed. When executing on PC
      having 64Mb of RAM, HotSpot 1.0.1-beta-C suffers intensive memory
      swapping when application consumes many memory, so that performance
      slows down essentially.

      The program "memleak005" displayed below measures time elapsed for
      allocation of lots of tiny instances, and reports the performance
      promlem if JVM spends more that 5 minutes to allocate new Object().
      This program is a simplified variant of the program "except001"
      displayed in the bugreport:
          #4248801 (P3/S5) slow memory allocation when heap is almost exhausted).

      After the bug #4248801 was fixed in HotSpot 1.0.1, these testing programs
      do not fail on computer having 128Mb of RAM installed. However, both these
      programs report slow memory allocation when executing on PC having 64Mb of
      RAM, e.g.:

          >>>> java -version
          java version "1.2.2"
          HotSpot VM (1.0.1, mixed mode, build c)

          >>>> java memleak005
          pool[589791]=new Object(); // elapsed 1.872s
          pool[2162707]=new Object(); // elapsed 1.051s
          pool[2457619]=new Object(); // elapsed 1.132s
          pool[3735135]=new Object(); // elapsed 323.605s
          Test failed: slow memory allocation.

      This looks like there was 2 problems leading to performance failure:
      - Some bug inside garbage collector (which is now fixed in HotSpot 1.0.1).
      - Contradiction between the "System Requirements" and HotSpots actual needs.
      While the first problem is resolved, the second still seems to remain.

      Possibly, System Requirements should be updated, so that HotSpot do not suffer
      performance failure on any computer conforming to System Requirements.

      Following is the source of the program "memleak005":

      /* @(#)memleak005.java 1.1 99/07/16
       * Copyright 99/07/16 Sun Microsystems, Inc.
       */

      import java.io.*;

      /**
       * This test checks time elapsed to allocate memory. The test is treated failed
       * if more then 5 minutes is spent to allocate ``last bytes'' of the memory.
       *
       * <p>The test is intended to verify the bug:
       * <br>&nbsp;&nbsp;
       * #4248801 (P3/S5) slow memory allocation when heap is almost exhausted
       * <br>Though the bug is treated fixed in HotSpot 1.0.1, memory allocation still
       * slows down when HotSpot runs on PC having 64Mb or less of memory installed.
       *
       * <p>HotSpot 2.0-devA (Win32) crashes on this test due to the known HotSpot bug:
       * <br>&nbsp;&nbsp;
       * #4239828 (P1/S4) 1.3c1: VM crashes when heap is exhausted
       *
       * <p>JDK 1.3 classic VM for Sparc may crash (core dump) due to the known bug:
       * <br>&nbsp;&nbsp;
       * #4245057 (P2/S3) VM crashes when heap is exhausted
       *
       * <p>The test is re-engineered from "except001" -- all checks are ommited
       * except of memory allocation speed.
       *
       * @author Eugene I. Latkin
       */
      public class memleak005 {
          private static final boolean MODE_VERBOSE = false;

          /**
           * Try to allocate upto 2<sup>23</sup> instances of the type
           * <code>Object</code>. Such instances are most fine-grained,
           * and thus they should occupy even smallest fragments of free
           * memory in the heap.
           *
           * <p>Break the test, if JVM has spent more than
           * 5 minutes to allocate latest portions of memory.
           */
          public static int run (String args[], PrintStream out) {
      // Repository for objects, which should be allocated:
      Object pool[];
      int index=0;
      try {
      pool = new Object [1<<23]; // ~8 millions
      } catch (OutOfMemoryError oome) {
      throw new Error("cannot initiate the test");
      };

      // Sum up time spent, when it was hard to JVM to allocate next object
      // (i.e.: when JVM has spent more than 1 second to allocate new object):
      double totalDelay = 0;
      long timeMark = System.currentTimeMillis();

              try {
      for (; index<pool.length; index++) {
      //-------------------------
      pool[index] = new Object();
      long nextTimeMark = System.currentTimeMillis();
      long elapsed = nextTimeMark - timeMark;
      timeMark = nextTimeMark;
      //----------------------
      if (elapsed > 1000) {
      double seconds = elapsed / 1000.0;
      if (MODE_VERBOSE)
      out.println(
      "pool[" + index + "]=new Object();" +
      " // elapsed " + seconds + "s");
      totalDelay += seconds;
      if (totalDelay > 300) {
      out.println("Test failed: slow memory allocation.");
      return 2;
      };
      };
      };
      } catch (OutOfMemoryError oome) {
      // Release memory, so that out.println() could work.
      pool = null;
      };

      if (MODE_VERBOSE)
      out.println("Test passed.");
        return 0;
          };
          
          /**
           * Re-call to <code>run(args,out)</code>, and return JCK-like exit status.
           * (The stream <code>out</code> is assigned to <code>System.out</code> here.)
           * @see #run(String[],PrintStream)
           */
          public static void main (String args[]) {
      int exitCode = run(args,System.out);
      System.exit(exitCode + 95);
      // JCK-like exit status.
          };
      }

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

            rschmidtsunw Rene Schmidt (Inactive)
            dkhukhrosunw Dmitry Khukhro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: