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

File.deleteOnExit() should only remember each pathname once

XMLWordPrintable

    • generic, x86
    • generic, linux

      Name: nt126004 Date: 02/05/2003


      FULL PRODUCT VERSION :
      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

      Also occurs with
      java version "1.4.1_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
      Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      [len@nepenthes len]$ rpm -query glibc
      glibc-2.2.4-24
      [len@nepenthes len]$ uname -a
      Linux nepenthes 2.4.19 #1 Tue Aug 6 12:16:08 NZST 2002 i686
      unknown
      [len@nepenthes len]$ cat /etc/redhat-release
      Red Hat Linux release 7.2 (Enigma)





      A DESCRIPTION OF THE PROBLEM :
      Calling File.deleteOnExit() always allocates memory outside
      the JVM, even if it has already been called for the same
      abstract pathname (even if it has already been called for
      the same File object!). Calling deleteOnExit() multiple
      times for the same abstract pathname should not consume more
      memory than calling it once.



      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.See supplied test code.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Memory should not be consumed when running the
      test program.

      Actual results is that the jvm increases in size unboundedly.




      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      class Test {
        // Call deleteOnExit() on the same File object.
        // Shouldn't consume memory but does.
        public static void main(String[] args) {
          try {
            java.io.File test = java.io.File.createTempFile("test",".tst");
            while (true) {
              test.deleteOnExit();
            }
          } catch (Exception e){e.printStackTrace();}
        }
      }

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

      CUSTOMER WORKAROUND :
      Do not call deleteOnExit more than once per abstract pathname.
      (Review ID: 180849)
      ======================================================================

            chegar Chris Hegarty
            nthompsosunw Nathanael Thompson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: