JDK-4813777 : File.deleteOnExit() should only remember each pathname once
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.4.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic,linux
  • CPU: generic,x86
  • Submitted: 2003-02-06
  • Updated: 2005-11-28
  • Resolved: 2005-11-28
Related Reports
Duplicate :  
Description
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) 
======================================================================

Comments
EVALUATION This issue will be fixed as part of the re-implementation of the deleteOnExit mechanism (4809375).
25-11-2005

EVALUATION Sounds reasonable. There are also other problems with the deleteOnExit structs that should be addressed at the same time. ###@###.### 2003-02-06
06-02-2003