Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1467

Memory leak using multipart provider

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Critical
    • 3.1.1.Final, 3.0.21.Final
    • 3.0.19.Final
    • jaxrs
    • None

    Description

      Issue to reopen RESTEASY-773

      Usage of the multipart provider causes a memory leak as the underlying mime4j implementation uses the File#deleteOnExit hook in the class TempFileStorageProvider:

      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 teh JVM exists. Long-running server libarreis should never use 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

              rhn-support-asoldano Alessio Soldano
              willem.salembier@gmail.com Willem Salembier (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: