Submitted On 15-NOV-2001
mindyleejones
Here's a good test program to illustrate the bug:
class test2
{
public static void main(String[] args){
try{
while (true){
File test = File.createTempFile("test",".tst");
test.deleteOnExit();
test.delete();
}
} catch (Exception e){e.printStackTrace();}
}
}
on a regular basis you can check the process heap size
growth (on solaris) by doing a :
/usr/proc/bin/pmap <pid> | grep heap
Once the file is deleted manually (and succesfully) with
the delete() function, there is no reason for the vm to
remember to deleteOnExit that file anymore. For server
applications that run for a long time, this can be a
serious leak.
Granted, this function may be intended for deleting
whatever may have the abstract filename path at VM exit,
regardless of how many files have been created and deleted
with that name. In that case I'd request, as a bug fix
(feature request), the ability to cancel the deleteOnExit
and free up the memory. At the very least the memory
implications of using this function should be documented in
the api docs.
Submitted On 05-SEP-2002
Lenbok
And here is another perturbation of the test program that
also illustrates the naivety of the current implementation:
class test3 {
public static void main(String[] args) {
try {
File test = File.createTempFile("test",".tst");
while (true) {
test.deleteOnExit();
}
} catch (Exception e){e.printStackTrace();}
}
}
The deleteOnExit() implementation doesn't even check to see
if it has already been called *for the same object*!
This is a terrible implementation. If the File is explicitly
delete()'d, then the deleteOnExit() should be cancelled. The
ability to explicitly cancel a deleteOnExit() should also be
provided.
(The category of this bug should be moved to reflect that it
is really File.deleteOnExit() that has the problems.)
Submitted On 30-MAY-2003
alangreenspan
There absolutely must be a way to cancel the pending
delete. We have observed this bug crashing servers that use
this API in temporary file manipulation. The bug is very
difficult to diagnose since the memory leak is in JVM private
memory, not the Java heap. Suggest adding
File.cancelDeleteOnExit in 1.4.2.
Submitted On 26-NOV-2003
varnam
As others mentioned , there should be a way to undo the
effect of DeleteOnExit call or JVM get rid of the
datastructure when actual file is deleted. Had to spend
three days to fugure out memory growth in jvm process
heap was becaue of this call to get rid of temporary files.
Submitted On 03-MAR-2004
forrestg
Unfortunately, Struts has now tripped over this bug. Web applications
using Struts 1.1 will now cause the container in which they execute to
core. Using previously posted test code I was able to trivially
reproduce cores with four distinct, current JVMs (Solaris, Darwin, AIX, and
Linux). The severity of this issue regardless of the number of votes
couldn't possibly be higher especially in light of the fact that it was
reported more than two years ago.
Submitted On 09-JUL-2004
matthias.ernst
We have been bitten by this one, too. It was very difficult to find and cost us a lot of work, nerves and customer reputation.
Submitted On 28-AUG-2005
matthias.ernst
The worst part: the data structure is kept in native memory. If it only was in Java heap, you might be able to diagnose the problem much quicker.
Submitted On 15-NOV-2005
philcam
Apache's commons-fileupload 1.0 package suffers from this bug. A work-around will be available in the 1.1 release, which is not yet available.
This bug should be resolved, as it negatively affects reliability in practically all production-grade jvm's.
Submitted On 27-JAN-2006
spainhou
This bug still exists and is causing tomcat to run out of heap space when generating a png or jpg image.
Submitted On 01-FEB-2006
javaweather
This bug took significant time to identify and track down as it inspection of native non-heap memory. It would be much appreciated if there was a way to default property of
ImageIO.setUseCache(false)
so having the memory leak would not be the default behaviour.
It would be much appreciated.
Thanks
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|