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