[rabbitmq-discuss] rabbitmq-c how many channels I need?

Alan Antonuk alan.antonuk at gmail.com
Wed Jun 19 18:43:11 BST 2013

rabbitmq-c uses a connection-wide memory pool that is recycled when you
call amqp_maybe_release_buffers(). When you call this function, some memory
is returned to the OS, but most of the memory is marked as unused and will
be reused by rabbitmq-c at some point in the future.

A couple rules of thumb for dealing with memory when using rabbitmq-c:

1. Anytime you call amqp_maybe_release_buffers(), any pointer returned from
rabbitmq-c before that call becomes invalid. Any use will lead to undefined

2. For RPC-style methods (amqp_queue_declare, amqp_exchange_declare,
amqp_basic_consume, anything that returns an amqp_*_ok_t *). You should
call amqp_maybe_release_buffers() immediately after you've finishing using
whatever that method returns: e.g.,:

amqp_queue_purge_ok_t *purge = amqp_queue_purge(connection, channel,
/* You should check to make sure purge != NULL, as that indicates failure */
int messages_purged = purge->message_count;
amqp_maybe_release_buffers(connection); /* NOTE: at this point, the purge
object is no longer valid */

3. When consuming messages you should call amqp_maybe_release_buffers()
after you've finished with each amqp_frame_t returned from

I cannot get any more specific than that without more information from you
(as Tim noted above).

Hope that helps

On Wed, Jun 19, 2013 at 4:25 AM, Tim Watson <tim at rabbitmq.com> wrote:

> On 19 Jun 2013, at 11:38, 3k4b251 wrote:
> > thank  you!    like  you say,  i  not  very  skillful  at  rabbitmq-c.
>   I
> > test  it  ,  I  found  that  if  I  use  the function
> > amqp_maybe_release_buffers()  after  amqp_queue_declare(),  the memory
>  stop
> > grow up .
> > but the function  amqp_basic_consume()  still  have high use  of
>  memory..?
> >
> Probably because it's (a) allocating data to manage the consumer/channel,
> (b) allocating buffers to handle the incoming data and (c) bringing data in
> from the kernel (via syscalls such as recv and so on) to user space so as
> to present it to your application. What exactly were you expecting to see
> once your application started consuming data from the queues? Of course
> it's going to use memory!? Are you actually seeing memory use that is
> unexpected here? Is that because it is (a) higher than you would expect to
> see, or (b) not getting released when you think it should? One of those two
> (latter) things might indicate a problem (either in your code or in some
> library you might be calling) but generally speaking "doing stuff" requires
> memory, so saying "still have high use of memory" isn't much to go on.
> _______________________________________________
> 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/20130619/1450fb98/attachment.htm>

More information about the rabbitmq-discuss mailing list