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/22 15:38:04 UTC

[GitHub] [pulsar] BewareMyPower commented on issue #8339: [C Client] Server resource exhaustion due to C client memory leak

BewareMyPower commented on issue #8339:
URL: https://github.com/apache/pulsar/issues/8339#issuecomment-714579552


   First there is a flaw of C client's design, the callback needs to manual free the `pulsar_message_id_t`:
   
   ```c
   static void asnyc_send_call_back(pulsar_result result, pulsar_message_id_t *msgId, void *ctx)
   {
           msg_ctx *pctx = (msg_ctx *)ctx;
   
           (void)msgId;  /* msgId points to a block of dynamic allocated memory, so the memory leaks here */
           /* ... */
   
           pulsar_message_free(pctx->msg);
           free(pctx);
   }
   ```
   
   For the backward compatibility, it cannot be changed. You need to call `pulsar_message_id_free` in the callback function, see https://github.com/apache/pulsar/blob/e31d18c00e4967779f84f55b489468ccc0b83a40/pulsar-client-cpp/include/pulsar/c/message_id.h#L54


----------------------------------------------------------------
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