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

FileDescriptor changes in JDK 8 causing OutOfMemory Errors

XMLWordPrintable

      Here is the evaluation:

      The observed behavior change was caused by the fix for JDK-7105952 (Improve
      finalisation for FileInputStream/FileOutputStream/RandomAccessFile).
      Without that fix, finalizer's code of a Input/Output Stream could close the
      file descriptor while it was still in use by another stream (e.g. see
      JDK-7082769).

      That fix for JDK-7105952 has caused a regression, similar to what the
      submitter is observing: JDK-7181793 (Socket getOutputStream create streams
      that cannot be GC'ed until Socket is closed).
      The real reason of that regression was that the method
      Socket.getOutputStream() created a new FileDescriptor object (wrapping the
      same native file descriptor) each time when called. This caused the list of
      the "parents" of the FileDescriptor to grow.

      Please also see the comments with additional details:
      https://bugs.openjdk.java.net/browse/JDK-7181793?focusedCommentId=12164619&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12164619

      It appears that the application needs to memorize created ReceiveSocketInputStream and
      ReceiveSocketOutputStream that reference given FileDescriptor and reuse them
      rather create new each time.

            igerasim Ivan Gerasimov
            shadowbug Shadow Bug
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: