azagrebin commented on a change in pull request #9693: [FLINK-13984] Separate 
on-heap and off-heap managed memory pools
URL: https://github.com/apache/flink/pull/9693#discussion_r333654190
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/memory/MemoryManager.java
 ##########
 @@ -300,31 +255,21 @@ public void allocatePages(Object owner, 
List<MemorySegment> target, int numPages
                                allocatedSegments.put(owner, segmentsForOwner);
                        }
 
-                       if (isPreAllocated) {
-                               for (int i = numPages; i > 0; i--) {
-                                       MemorySegment segment = 
memoryPool.requestSegmentFromPool(owner);
-                                       target.add(segment);
-                                       segmentsForOwner.add(segment);
-                               }
-                       }
-                       else {
-                               for (int i = numPages; i > 0; i--) {
-                                       MemorySegment segment = 
memoryPool.allocateNewSegment(owner);
-                                       target.add(segment);
-                                       segmentsForOwner.add(segment);
-                               }
-                               numNonAllocatedPages -= numPages;
+                       for (int i = numPages; i > 0; i--) {
+                               MemorySegment segment = 
allocateManagedSegment(memoryType, owner);
+                               target.add(segment);
+                               segmentsForOwner.add(segment);
                        }
+                       numNonAllocatedPages -= numPages;
                }
                // -------------------- END CRITICAL SECTION -------------------
        }
 
        /**
-        * Tries to release the memory for the specified segment. If the 
segment has already been released or
-        * is null, the request is simply ignored.
+        * Tries to release the memory for the specified segment.
         *
-        * <p>If the memory manager manages pre-allocated memory, the memory 
segment goes back to the memory pool.
-        * Otherwise, the segment is only freed and made eligible for 
reclamation by the GC.
+        * <p>If the segment has already been released or is null, the request 
is simply ignored.
 
 Review comment:
   Remove completely?
   
   I can change it to:
   `If the segment has already been released, it is only freed. If it is null 
or has no owner, the request is simply ignored.`
   
   Also, two more things came into my mind, we should not release budget if 
there is no such segment registered for this owner (e.g. double release) and we 
should always try to remove the segment even if it is freed because it might 
have been freed outside but not released.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to