JDK-8025826 : (bf) DirectByteBuffer should be more aggressive with cleanups
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2013-10-02
  • Updated: 2013-10-02
  • Resolved: 2013-10-02
Related Reports
Duplicate :  
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.
Comments
Ah! Thanks, please close as dup. I will provide the patch for 6857566 instead.
02-10-2013

Seems to be a duplicate of 6857566. If the submitter agrees then I will close it as a dup.
02-10-2013