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

Loading java.lang.Shutdown when permanent generation is full crashes JVM

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 1.4.2
    • Fix Version/s: 5.0
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      tiger
    • CPU:
      generic
    • OS:
      generic

      Description

      Compile the follwoing program:

          import java.util.LinkedList;

          public class InternStringALot {
              // The point of this class is to intern a lot of Strings,
              // to fill up the permanent generation and fail an assertion
              // during shutdown.
              // This is *not* a bug with interning Strings, just that
              // this was the easiest way I could think of to fill up
              // the permanent generation.
              //
              // Run with:
              // java -XX:MaxPermSize=4M -XX:+PrintGCDetails -XX:+PrintHeapAtGC InternStringALot

              public static void main(String arg[]) {
                  long count = 20000;
                  String base = "ABCEDFEGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz";
                  if (arg.length > 0) {
                      try {
                          count = Long.parseLong(arg[0]);
                      } catch (NumberFormatException nfe) {
                          // Just ignore it.
                      }
                  }
                  if (arg.length > 1) {
                      base = arg[1];
                  }
                  System.out.println("Running with ");
                  System.out.println(" base: " + base);
                  System.out.println(" count: " + Long.toString(count));
                  long i = 0;
                  try {
                      for (i = 0; i < count; i += 1) {
                          list.add(base.concat(Long.toString(i)).intern());
                      }
                  } catch (OutOfMemoryError oome) {
                      System.out.println("Caught OutOfMemoryError at iteration: " +
                                         Long.toString(i));
                  }
              }

              private static LinkedList list = new LinkedList();
          }

      and run it with the command line:

          % java -XX:MaxPermSize=4M InternStringALot

      and you should produce the result:

          Running with
      base: ABCEDFEGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz
      count: 20000
          Caught OutOfMemoryError at iteration: 18345
          #
          # HotSpot Virtual Machine Error, Internal Error
          # Please report this error at
          # http://java.sun.com/cgi-bin/bugreport.cgi
          #
          # Java VM: Java HotSpot(TM) Client VM (1.4.2-beta-b08 mixed mode)
          #
          # Error ID: 455843455054494F4E530E4350500104 01
          #
          # Problematic Thread: prio=5 tid=0x0002e158 nid=0x1 runnable
          #

          Heap at VM Abort:
          Heap
           def new generation total 2112K, used 0K [0xf5000000, 0xf5220000, 0xf5710000)
            eden space 2048K, 0% used [0xf5000000, 0xf5000000, 0xf5200000)
            from space 64K, 0% used [0xf5200000, 0xf5200000, 0xf5210000)
            to space 64K, 0% used [0xf5210000, 0xf5210000, 0xf5220000)
           tenured generation total 1408K, used 514K [0xf5710000, 0xf5870000, 0xf9000000)
             the space 1408K, 36% used [0xf5710000, 0xf5790870, 0xf5790a00, 0xf5870000)
           compacting perm gen total 4096K, used 4095K [0xf9000000, 0xf9400000, 0xf9400000)
             the space 4096K, 99% used [0xf9000000, 0xf93fffd0, 0xf9400000, 0xf9400000)
          Abort (core dumped)

      The problem is that permanent generation is full when the JVM goes
      to run the shutdown hooks by loading java.lang.Shutdown.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jloizeausunw Jane Loizeaux (Inactive)
              Reporter:
              pbk Peter Kessler
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: