Uploaded image for project: 'James Mime4j'
  1. James Mime4j
  2. MIME4J-251

Memory leak in TempFileStorageProvider

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Critical
    • Resolution: Unresolved
    • 0.7.2
    • None
    • project
    • None

    Description

      Usage of the File#deleteOnExit hook in the class TempFileStorageProvider causes a memory leak for long-running servers:

      public StorageOutputStream createStorageOutputStream() throws IOException {
              File file = File.createTempFile(prefix, suffix, directory);
              file.deleteOnExit();
       
              return new TempFileStorageOutputStream(file);
          }
      

      The JDK keeps a set of File references (even when already deleted) in memory until the JVM exists. This set grows infinitely. Server-side libraries should never call File#deleteOnExit

      https://bugs.openjdk.java.net/browse/JDK-4872014
      https://bugs.openjdk.java.net/browse/JDK-4513817
      class DeleteOnExitHook {
      private static LinkedHashSet<String> files = new LinkedHashSet<>();

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              wsalembi Willem Salembier
              Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated: