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

(bf) DirectByteBuffer should be more aggressive with cleanups

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None

      Description

      Current ByteBuffer.allocateDirect() code uses sun.misc.Cleaner to deallocate the native memory. Cleaner is being invoked by the ReferenceHandler thread, which is problematic for several reasons. First, there is no feedback between allocation and deallocation of DirectByteBuffers. That means that with plenty allocators we overrun the cleanup threads, and catch fire (OOME). Second, ReferenceHandler is the single thread who's job is to enqueue the references on their relevant queues. If there are many references currently in flight in the VM, Cleaners are getting penalized in their cleanups.

      In the end, that means the simple loop:
       while(true) ByteBuffer.allocateDirect(100);
      ...can put all of the direct buffer users down on the knees, and severely handicap JRE performance.

      We should be more aggressive in DIrectByteBuffer cleanups.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: