NicoK commented on a change in pull request #6809: [FLINK-10491][network] Pass 
BufferPoolOwner in the constructor of LocalBufferPool
URL: https://github.com/apache/flink/pull/6809#discussion_r223748143
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/buffer/LocalBufferPool.java
 ##########
 @@ -349,11 +346,13 @@ public void setNumBuffers(int numBuffers) throws 
IOException {
 
                        returnExcessMemorySegments();
 
-                       // If there is a registered owner and we have still 
requested more buffers than our
-                       // size, trigger a recycle via the owner.
-                       if (owner != null && numberOfRequestedMemorySegments > 
currentPoolSize) {
-                               
owner.releaseMemory(numberOfRequestedMemorySegments - currentPoolSize);
-                       }
+                       numReleased = numberOfRequestedMemorySegments - 
currentPoolSize;
+               }
+
+               // If there is a registered owner and we have still requested 
more buffers than our
+               // size, trigger a recycle via the owner.
+               if (owner != null && numReleased > 0) {
+                       owner.releaseMemory(numReleased);
 
 Review comment:
   I'd say, this is safe.
   Since recycled memory segments will eventually become available, a blocking 
call by any other thread on getting a buffer will still wait until it is 
actually recycled. What other interactions were you thinking about?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to