Open fanyeren opened 11 years ago
I bumped to the same issue and got myself some time to debug this. The annoying memory leak only happens when the message contains "header" property. For example, a few thousands messages like this will cause significant memory leak.
$VAR1 = {
'body' => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'redelivered' => 0,
'props' => {
'priority' => 0,
'headers' => {},
'content_type' => 'text/plain',
'delivery_mode' => 2,
'content_encoding' => 'UTF-8'
},
'routing_key' => 'hello',
'delivery_tag' => '',
'message_count' => 15693,
'exchange' => ''
};
while this one won't:
$VAR1 = {
'body' => 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
'redelivered' => 0,
'props' => {
'priority' => 0,
'content_type' => 'text/plain',
'delivery_mode' => 2,
'content_encoding' => 'UTF-8'
},
'routing_key' => 'hello',
'delivery_tag' => '',
'message_count' => 30491,
'exchange' => ''
};
Then I took a look at the source code and found these lines in amqp_framing.c
:
if (flags & AMQP_BASIC_HEADERS_FLAG) {
table_result = amqp_decode_table(encoded, pool, &(p->headers), &offset);
AMQP_CHECK_RESULT(table_result);
}
I did a quick test by removing the line that calls amqp_decode_table
then recompiled the module. Apparently, the memory leak issue didn't happen anymore. So I think there's something wrong with amqp_decode_table
function when dealing with header property.
It turns out that you forgot to free(entries);
in amqp_decode_table
function.
Do you need a pull request for this ?
i have a simple test program,
while (1) { my $rv = $mq->recv(); my $packed = $rv->{body};
}
The memory usage rises time by time, and finally, OOM Killer.
64G RAM, centos linux 5.8