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

File.delete() should remove its path from DeleteOnExitHook.files

    XMLWordPrintable

    Details

    • Subcomponent:
    • Understanding:
      Cause Known

      Description

      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.


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bpb Brian Burkhalter
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated: