[rabbitmq-discuss] rabbitmq-c memory leak?

Alan Antonuk alan.antonuk at gmail.com
Sat Apr 5 16:44:21 BST 2014


SimpleAmqpClient should call MaybeReleaseBuffersOnChannel, which if it has
no frames enqueued, should call amqp_maybe_release_buffers_on_channel(),
which if rabbitmq-c doesn't have any frames lying around will recycle the
pool associated with that channel. If this really is a bug (possible...) it
would be good to know which channel(s) SimpleAmqpClient is publishing on,
and which channel(s) are growing without bound (e.g., which entry in
amqp_connection_state_t.pool_table).

-Alan


On Thu, Apr 3, 2014 at 5:19 PM, Dushin Fred <fred at dushin.net> wrote:

>
> I have written a simple test program using the SimpleAqmpClient library
> (which in turn uses the rabbitmq-c library), which seems to illustrate a
> memory leak, of sorts.
>
> The program is a simple main, which pre-allocates a string message, and
> then calls BasicPublish on a channel in a loop, all single threaded.
>  Effectively:
>
>         auto envelope = BasicMessage::Create(random_data(message_size));
>         for (unsigned i = 0;  i < num_messages;  ++i)
>         {
>             channel->BasicPublish(exchange_name, routing_key, envelope);
>         }
>
> The problem is that the memory image of this process seems to grow without
> bounds.  The memory all seems to be allocated in amqp_pool_alloc (as
> expected), when calling wait_frame_inner -> amqp_handle_input.  The memory
> is not orphaned -- i.e., it seems to get cleaned up at shutdown, so it
> doesn't show up as a leak in a leak detector tool, such a
> Instruments/DTrace, or valgrind, or purify, etc.  But I don't see where the
> memory is every de-allocated, which will spell doom for an application that
> is designed to never terminate.
>
> I am attaching a screenshot from an Instruments run, to give some context.
>  The code is here:
>
> https://github.com/fadushin/sandbox/blob/master/cpp/rabbitmq/sender.cpp
>
> This was run against RabbitMQ 3.2.4, using rabbitmq-c 0.5.0 and
> SimpleAmqpClient 2.3, compiled using Clang 5.0 on OS X.9 (Mavericks).
>
> Has anyone seen this behavior?  Am I missing something in my use of
> BasicPublish, that is not telling the rabbitmq-c library to free memory in
> the "amqp pool"?  It doesn't seem to make a difference whether I am
> actively pulling messages off the queue from a separate process, or even
> whether there is a queue bound to the exchange to which I am publishing
> messages.  (Not that I would expect it to)
>
> -Fred
>
> encl.
>
>
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140405/f0fea407/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PastedGraphic-3.png
Type: image/png
Size: 422159 bytes
Desc: not available
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140405/f0fea407/attachment.png>


More information about the rabbitmq-discuss mailing list