You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/10/16 22:41:39 UTC

[GitHub] [pulsar] pkumar-singh commented on a change in pull request #8283: [C++] Client is allocating buffer bigger than needed

pkumar-singh commented on a change in pull request #8283:
URL: https://github.com/apache/pulsar/pull/8283#discussion_r506750842



##########
File path: pulsar-client-cpp/lib/Commands.cc
##########
@@ -675,7 +675,7 @@ uint64_t Commands::serializeSingleMessageInBatchWithPayload(const Message& msg,
                   << batchPayLoad.writableBytes() << "] can't accomodate new payload [" << requiredSpace
                   << "] - expanding the batchPayload buffer");
         SharedBuffer buffer = SharedBuffer::allocate(batchPayLoad.readableBytes() +
-                                                     std::max(requiredSpace, maxMessageSizeInBytes));
+                                                     std::min(requiredSpace, maxMessageSizeInBytes));

Review comment:
       Why even do minimum then. Internally it's any way a vector so it will reallocate. 




----------------------------------------------------------------
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:
users@infra.apache.org