A DESCRIPTION OF THE REQUEST :
When calling File.deleteOnExit() it adds a path to the static list DeleteOnExitHook.files so that it can be deleted when the vm terminates. However there is no need for that when the file was deleted previously by File.delete().
Moreover a careful developer might think to create a temporary file which she deletes later within her application by File.delete(), but just in case something goes wrong in between she also calls File.deleteOnExit() after creation. Now if that application would create an infinite amount of such temporary files, it would create a subtile memory leak, as File.deleteOnExit() grows an unbounded list which is unaffected by File.delete().
JUSTIFICATION :
I ask to add the said feature to avoid this subtle opportunity to create a memory leak in case of an application which needs to create endless temporary files and deletes them by itself.
When calling File.deleteOnExit() it adds a path to the static list DeleteOnExitHook.files so that it can be deleted when the vm terminates. However there is no need for that when the file was deleted previously by File.delete().
Moreover a careful developer might think to create a temporary file which she deletes later within her application by File.delete(), but just in case something goes wrong in between she also calls File.deleteOnExit() after creation. Now if that application would create an infinite amount of such temporary files, it would create a subtile memory leak, as File.deleteOnExit() grows an unbounded list which is unaffected by File.delete().
JUSTIFICATION :
I ask to add the said feature to avoid this subtle opportunity to create a memory leak in case of an application which needs to create endless temporary files and deletes them by itself.
- duplicates
-
JDK-6664633 DeleteOnExitHook leaks memory (with fix)
- Closed
- relates to
-
JDK-4872014 File.cancelDeleteOnExit() to avoid JVM crashes
- Open
- links to