<div dir="ltr"><div style>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.</div>
<div style><br></div><div style>A couple rules of thumb for dealing with memory when using rabbitmq-c:</div><div style><br></div><div style>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 behavior.</div>
<div style><br></div><div style>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&#39;ve finishing using whatever that method returns: e.g.,:</div>
<div style><br></div><div style>amqp_queue_purge_ok_t *purge = amqp_queue_purge(connection, channel, amqp_cstring_bytes(&quot;myqueue&quot;);</div><div style>/* You should check to make sure purge != NULL, as that indicates failure */</div>
<div style>int messages_purged = purge-&gt;message_count;</div><div style>amqp_maybe_release_buffers(connection); /* NOTE: at this point, the purge object is no longer valid */</div><div style><br></div><div style>3. When consuming messages you should call amqp_maybe_release_buffers() after you&#39;ve finished with each amqp_frame_t returned from amqp_simple_wait_frame().�</div>
<div style><br></div><div style>I cannot get any more specific than that without more information from you (as Tim noted above).</div><div style><br></div><div style>Hope that helps</div><div style>-Alan</div><div style><br>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 19, 2013 at 4:25 AM, Tim Watson <span dir="ltr">&lt;<a href="mailto:tim@rabbitmq.com" target="_blank">tim@rabbitmq.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 19 Jun 2013, at 11:38, 3k4b251 wrote:<br>
&gt; thank �you! � �like �you say, �i �not �very �skillful �at �rabbitmq-c. � � I<br>
&gt; test �it �, �I �found �that �if �I �use �the function<br>
&gt; amqp_maybe_release_buffers() �after �amqp_queue_declare(), �the memory �stop<br>
&gt; grow up .<br>
&gt; but the function �amqp_basic_consume() �still �have high use �of �memory..?<br>
&gt;<br>
<br>
</div>Probably because it&#39;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&#39;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 &quot;doing stuff&quot; requires memory, so saying &quot;still have high use of memory&quot; isn&#39;t much to go on.<br>

<div class="HOEnZb"><div class="h5">_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></div></blockquote></div><br></div>