<div dir="ltr">You need to call amqp_maybe_releae_buffers() after amqp_tx_commit().<div><br></div><div>The rule of thumb for rabbitmq-c is if the library returns something to you, you should release it when you&#39;re done with it by calling that function.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 1, 2013 at 6:08 AM, Haster <span dir="ltr">&lt;<a href="mailto:haster2004@yandex.ru" target="_blank">haster2004@yandex.ru</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi there!<br>
<br>
I try to use transactions in my producer. And I found that when I send many<br>
messages - my app eat a lot of memory.<br>
<br>
If I dismiss transaction feature - memory consumption is normal<br>
<br>
Maybe there is memory leak in amqp_tx_commit? Or maybe I have to call some<br>
function to clean something?<br>
<br>
my test case is below:<br>
const char * const host = &quot;localhost&quot;;<br>
int port = 5672;<br>
const char * const user = &quot;admin&quot;;<br>
const char * const pass = &quot;password&quot;;<br>
amqp_channel_t channel_exchange = 4;<br>
amqp_channel_t channel_queue = 5;<br>
const char *exchange = &quot;haster_ex&quot;;<br>
<br>
void main () {<br>
� amqp_connection_state_t conn = amqp_new_connection();<br>
� if (!conn) { cout &lt;&lt; &quot;Connection error\n&quot;; return;<br>
� }<br>
<br>
� int sockfd = amqp_open_socket(host, port); �//5672<br>
� if (sockfd &lt; 0) { cout &lt;&lt; &quot;Opening socket error\n&quot;; return; �}<br>
<br>
� amqp_set_sockfd(conn, sockfd);<br>
<br>
� amqp_rpc_reply_t reply = amqp_login(conn, &quot;/&quot;, 0, 131072, 0,<br>
AMQP_SASL_METHOD_PLAIN, user, pass);<br>
� if (reply.reply_type != AMQP_RESPONSE_NORMAL)<br>
{amqp_destroy_connection(conn); cout &lt;&lt; &quot;Login error\n&quot;; return;}<br>
<br>
� amqp_channel_open(conn, channel_exchange);<br>
� amqp_rpc_reply_t res = amqp_get_rpc_reply(conn);<br>
� if (res.reply_type != AMQP_RESPONSE_NORMAL) {cout &lt;&lt; &quot;Channel open<br>
error\n&quot;; amqp_connection_close(conn, AMQP_REPLY_SUCCESS);<br>
amqp_destroy_connection(conn);return;}<br>
<br>
<br>
* �amqp_tx_select(conn, channel_exchange); � // If comment this - all is OK*<br>
� res = amqp_get_rpc_reply(conn);<br>
� if (res.reply_type != AMQP_RESPONSE_NORMAL) {cout &lt;&lt; &quot;Select error\n&quot;;<br>
amqp_connection_close(conn, AMQP_REPLY_SUCCESS);<br>
amqp_destroy_connection(conn);return;}<br>
<br>
� amqp_bytes_t message_bytes, routingKey_bytes, exchange_bytes;<br>
� exchange_bytes.bytes = (void*)exchange;<br>
� exchange_bytes.len = strlen(exchange);<br>
� message_bytes.bytes = (void*)&quot;Privrr&quot;;<br>
� message_bytes.len = 6;<br>
� routingKey_bytes.bytes = (void*)&quot;key&quot;;<br>
� routingKey_bytes.len = 3;<br>
� amqp_basic_properties_t props;<br>
� props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG;<br>
� props.delivery_mode = 2;<br>
� props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG;<br>
� props.content_type = amqp_cstring_bytes(&quot;text/plain&quot;);<br>
<br>
� amqp_bytes_t expiration;<br>
� expiration.bytes = (void*)&quot;1000&quot;;<br>
� expiration.len = 4;<br>
� props.expiration = expiration;<br>
� props._flags |= AMQP_BASIC_EXPIRATION_FLAG;<br>
<br>
� while (1) {<br>
� � int r = amqp_basic_publish(conn, channel_exchange, exchange_bytes,<br>
routingKey_bytes, �1, 0, &amp;props, message_bytes);<br>
<br>
* � �amqp_tx_commit(conn, channel_exchange); �// if comment it - all is OK<br>
� � amqp_get_rpc_reply(conn);*<br>
� � //die_on_amqp_error(amqp_get_rpc_reply(conn), &quot;Commit error&quot;);<br>
� }<br>
� char ch;<br>
� cin &gt;&gt; ch;<br>
}<br>
<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://rabbitmq.1065348.n5.nabble.com/rabbitmq-c-amqp-tx-commit-leak-memory-tp27717.html" target="_blank">http://rabbitmq.1065348.n5.nabble.com/rabbitmq-c-amqp-tx-commit-leak-memory-tp27717.html</a><br>

Sent from the RabbitMQ mailing list archive at Nabble.com.<br>
_______________________________________________<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>
</blockquote></div><br></div>