You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/12/02 09:39:34 UTC

[GitHub] [arrow] zhztheplayer commented on a change in pull request #11800: ARROW-14923: [Java] AllocationListener should be called during ownership transferring

zhztheplayer commented on a change in pull request #11800:
URL: https://github.com/apache/arrow/pull/11800#discussion_r760915732



##########
File path: java/memory/memory-core/src/main/java/org/apache/arrow/memory/BufferLedger.java
##########
@@ -364,8 +364,12 @@ boolean transferBalance(final ReferenceManager targetReferenceManager) {
             targetReferenceManager.getAllocator().getName());
       }
 
-      boolean overlimit = targetAllocator.forceAllocate(allocationManager.getSize());
-      allocator.releaseBytes(allocationManager.getSize());
+      long size = allocationManager.getSize();
+      targetAllocator.getListener().onPreAllocation(size);
+      boolean overlimit = targetAllocator.forceAllocate(size);
+      targetAllocator.getListener().onAllocation(size);
+      allocator.releaseBytes(size);
+      allocator.getListener().onRelease(size);

Review comment:
       For example. Buffer1 and Buffer2 are shared and were created by Allocator1 and Allocator2. Allocator1 has a listener assigned but Allocator2 doesn't have one. Once the memory ownership is transferred from Buffer1 to Buffer2, then the listener will not be aware of that transferring, and `listener.free()` will never be called even we close both Buffer1 and Buffer2.
   




-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org