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

Heap Dump on Out of Memory Error fails to write file when -XX:HeapDumpPath is set

XMLWordPrintable

    • x86_64
    • linux

      FULL PRODUCT VERSION :
      java version "1.8.0_72"
      Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode)


      FULL OS VERSION :
      4.1.7-15.23.amzn1.x86_64 #1 SMP Mon Sep 14 23:20:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/home/ec2-user/logs"

      A DESCRIPTION OF THE PROBLEM :
      When -XX:HeapDumpPath is set along with -XX:+HeapDumpOnOutOfMemoryError and an OOM error occurs, the heap dump file fails to write with the following type of error

      java.lang.OutOfMemoryError: Java heap space
      Dumping heap to "/home/ec2-user/logs" ...
      Unable to create "/home/ec2-user/logs": No such file or directory

      The location does exist and is normally writable by the user running the java application.

      If -XX:HeapDumpPath is not set then a dump file is written successfully to the current directory

      REGRESSION. Last worked in version 7u76

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the java application with -XX:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath set.

      Run an application that will trigger an OOM error.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected Result is that the heap dump file is written to the path specified by -XX:HeapDumpPath

      Actual result is that the file is not written.
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Dumping heap to "/home/ec2-user/logs" ...
      Unable to create "/home/ec2-user/logs": No such file or directory


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      // OOM Generator
      new Thread(new Runnable() {

      @Override
      public void run()
      {
      int iteratorValue = 20;
      System.out.println("\n=================> OOM test started..\n");
      for (int outerIterator = 1; outerIterator < 20; outerIterator++) {
      System.out.println("Iteration " + outerIterator + " Free Mem: " + Runtime.getRuntime().freeMemory());
      int loop1 = 2;
      int[] memoryFillIntVar = new int[iteratorValue];
      // feel memoryFillIntVar array in loop..
      do {
      memoryFillIntVar[loop1] = 0;
      loop1--;
      } while (loop1 > 0);
      iteratorValue = iteratorValue * 5;
      System.out.println("\nRequired Memory for next loop: " + iteratorValue);
      try
      {
      Thread.sleep(1000);
      }
      catch (InterruptedException e)
      {
      // TODO Auto-generated catch block
      e.printStackTrace();
      }
      }
      }
      }).start();

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Omit -XX:HeapDumpPath from the java args

            fmatte Fairoz Matte
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: