You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gluten.apache.org by "wForget (via GitHub)" <gi...@apache.org> on 2024/10/09 03:13:44 UTC

Re: [PR] [CORE] Update AllocationListener usage after successfully releasing memory [incubator-gluten]

wForget commented on code in PR #7396:
URL: https://github.com/apache/incubator-gluten/pull/7396#discussion_r1792727265


##########
cpp/core/memory/MemoryAllocator.cc:
##########
@@ -50,9 +50,13 @@ bool ListenableMemoryAllocator::allocateAligned(uint64_t alignment, int64_t size
 
 bool ListenableMemoryAllocator::reallocate(void* p, int64_t size, int64_t newSize, void** out) {
   int64_t diff = newSize - size;
-  updateUsage(diff);
+  if (diff > 0) {
+    updateUsage(diff);
+  }
   bool succeed = delegated_->reallocate(p, size, newSize, out);
-  if (!succeed) {
+  if (succeed && diff < 0) {
+    updateUsage(diff);
+  } else if (!succeed && diff > 0) {
     updateUsage(-diff);
   }
   return succeed;

Review Comment:
   thanks, changed



-- 
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: commits-unsubscribe@gluten.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@gluten.apache.org
For additional commands, e-mail: commits-help@gluten.apache.org