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/20 16:02:57 UTC

[GitHub] [pulsar] bschofield opened a new issue #8311: Memory leak in C client, inside function handle_producer_send()

bschofield opened a new issue #8311:
URL: https://github.com/apache/pulsar/issues/8311


   **Describe the bug**
   
   When a message is asynchronously sent using the C client, the function *pulsar_producer_send_async()* (in file *c_Producer.cc*) will set up a shim function *handle_producer_send()* to handle the callback.
   
   Inside *handle_producer_send()*, a `pulsar_message_id_t` is created:
   
   ```C++
           pulsar_message_id_t *c_message_id = new pulsar_message_id_t;
   ```
   
   I cannot find where this memory is freed. It seems to be the source of a memory leak.
   
   Because the amount of memory leaked is so small, the issue only really becomes visible after sending tens or hundreds of millions of messages.
   
   **To Reproduce**
   
   1. Run a program using the C/C++ translation layer (e.g. anything using the golang -> C -> C++ client), using `valgrind --leak-check=full`.
   2. Look at the valgrind output. Scroll down to the last of the leak reports. There should be a report like this:
   
   ```
   ==132== 4,004,096 (1,234,208 direct, 2,769,888 indirect) bytes in 77,138 blocks are definitely lost in loss record 22,211 of 22,211
   ==132==    at 0x4835DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
   ==132==    by 0x4AEEB03: handle_producer_send(pulsar::Result, pulsar::MessageId, void (*)(pulsar_result, _pulsar_message_id*, void*), void*) (c_Producer.cc:42)
   ...
   ```
   
   **Expected behavior**
   
   The C client should not leak memory in normal use.
   
   **Additional information**
   
   [Confirmed as a bug here](https://apache-pulsar.slack.com/archives/C5ZSVEN4E/p1603209067051000).
   


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



[GitHub] [pulsar] bschofield commented on issue #8311: Memory leak in ~C~ golang client, inside function handle_producer_send()

Posted by GitBox <gi...@apache.org>.
bschofield commented on issue #8311:
URL: https://github.com/apache/pulsar/issues/8311#issuecomment-713006747


   After discussion with @merlimat, it seems that the behavior of the C interface code is intended, and it has to be that way due to legacy client constraints. It is intended that clients using the C interface call *pulsar_message_id_free()* after a callback with a result of `pulsar_result_Ok`.
   
   Currently, the cgo interface appears to fail to make that call. Hence, the bug is in the pulsar cgo interface code.


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



[GitHub] [pulsar] wolfstudy closed issue #8311: Memory leak in golang client (cgo interface)

Posted by GitBox <gi...@apache.org>.
wolfstudy closed issue #8311:
URL: https://github.com/apache/pulsar/issues/8311


   


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