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

-XX:+HeapDumpOnOutOfMemoryError does not work when OOM caused by failure to alloc native thread

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P3 P3
    • None
    • 6
    • hotspot
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_11"
      Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
      Java HotSpot(TM) Server VM (build 11.0-b16, mixed mode)

      and

      java version "1.7.0-ea"
      Java(TM) SE Runtime Environment (build 1.7.0-ea-b39)
      Java HotSpot(TM) Server VM (build 14.0-b06, mixed mode)

      FULL OS VERSION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      -XX:+HeapDumpOnOutOfMemoryError does not work when OOM caused by "unable to create new native thread"

      Full dump:

      Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
              at java.lang.Thread.start0(Native Method)
              at java.lang.Thread.start(Thread.java:597)
              at test.ConsumeThreads.main(ConsumeThreads.java:20)


      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Did not try

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Using test program ConsumeThreads.java (provided below) and the command line:
      java -server -XX:+HeapDumpOnOutOfMemoryError test.ConsumeThreads

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected heap dump, did not get one
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.lang.OutOfMemoryError: unable to create new native thread
              at java.lang.Thread.start0(Native Method)
              at java.lang.Thread.start(Thread.java:597)
              at test.ConsumeThreads.main(ConsumeThreads.java:14)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.util.ArrayList;

      public class ConsumeThreads
      {
          public static void main(String[] args)
          {
              ArrayList list = new ArrayList();
              
              while (true)
              {
                  Thread thread = new MyThread();
                  thread.start();
                  list.add(thread);
              }
          }
          
          static class MyThread
          extends Thread
          {
              public void run()
              {
                  synchronized(this)
                  {
                      try
                      {
                          this.wait();
                      }
                      catch (InterruptedException e)
                      {
                          e.printStackTrace();
                      }
                  }
              }
          }

      }
      ---------- END SOURCE ----------

            coleenp Coleen Phillimore
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: