lhotari commented on code in PR #21790:
URL: https://github.com/apache/pulsar/pull/21790#discussion_r1435162824


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/MemoryLimitController.java:
##########
@@ -47,6 +47,16 @@ public MemoryLimitController(long memoryLimitBytes, long 
triggerThreshold, Runna
 
     public void forceReserveMemory(long size) {
         long newUsage = currentUsage.addAndGet(size);
+        if (size < 0 && newUsage - size > memoryLimit

Review Comment:
   I'd suggest that we add an assert here and instead fix the logic in 
https://github.com/apache/pulsar/blob/aba50f2a276412bc43a4652b9ce303d384f71966/pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java#L329
 to call forceReserveMemory(delta) if delta > 0 and call releaseMemory(-delta) 
if delta < 0. no call if delta == 0. WDYT?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to