dschneider-pivotal commented on code in PR #7621: URL: https://github.com/apache/geode/pull/7621#discussion_r859086223
########## geode-core/src/main/java/org/apache/geode/internal/net/BufferPool.java: ########## @@ -90,46 +87,46 @@ static boolean computeUseDirectBuffers() { * * @return a byte buffer to be used for sending on this connection. */ - public ByteBuffer acquireDirectSenderBuffer(int size) { + public PooledByteBuffer acquireDirectSenderBuffer(int size) { return acquireDirectBuffer(size, true); } - public ByteBuffer acquireDirectReceiveBuffer(int size) { + public PooledByteBuffer acquireDirectReceiveBuffer(int size) { return acquireDirectBuffer(size, false); } /** * try to acquire direct buffer, if enabled by configuration */ - private ByteBuffer acquireDirectBuffer(int size, boolean send) { - ByteBuffer result; + private PooledByteBuffer acquireDirectBuffer(int size, boolean send) { + ByteBuffer byteBuffer; if (useDirectBuffers) { if (size <= MEDIUM_BUFFER_SIZE) { - result = acquirePredefinedFixedBuffer(send, size); + byteBuffer = acquirePredefinedFixedBuffer(send, size); } else { - result = acquireLargeBuffer(send, size); + byteBuffer = acquireLargeBuffer(send, size); } - if (result.capacity() > size) { - result.position(0).limit(size); - result = result.slice(); + if (byteBuffer.capacity() > size) { + byteBuffer.position(0).limit(size); + return new PooledByteBuffer(byteBuffer, byteBuffer.slice()); Review Comment: I think these transient allocations are a drop in the bucket compared to the total number of transient allocations we have for each cache operation. And these transient instances are very small. I don't think it was worth using an internal JDK feature which is subject to change in any jdk release to avoid this transient. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@geode.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org