|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-10-24 21:44 UTC] imprec at gmail dot com
Description:
------------
When running code whith php compiled with "--enable-debug", memory leak is
reported :
[Wed Oct 24 23:42:24 2012] Script: '/private/tmp/RabbitMQ/test.php'
/usr/local/src/amqp-1.0.7/amqp_connection.c(407) : Freeing 0x1030259F0 (6
bytes),
script=/private/tmp/RabbitMQ/test.php
Last leak repeated 1 time
[Wed Oct 24 23:42:24 2012] Script: '/private/tmp/RabbitMQ/test.php'
/usr/local/src/amqp-1.0.7/amqp_connection.c(425) : Freeing 0x103026828 (6
bytes),
script=/private/tmp/RabbitMQ/test.php
Last leak repeated 1 time
[Wed Oct 24 23:42:24 2012] Script: '/private/tmp/RabbitMQ/test.php'
/usr/local/src/amqp-1.0.7/amqp_connection.c(459) : Freeing 0x103026A78 (2
bytes),
script=/private/tmp/RabbitMQ/test.php
Last leak repeated 1 time
=== Total 6 memory leaks detected ===
Test script:
---------------
The script is this one :
function amqp_connection() {
$amqpConnection = new AMQPConnection();
$amqpConnection->setLogin("guest");
$amqpConnection->setPassword("guest");
$amqpConnection->setVhost("/");
$amqpConnection->connect();
if(!$amqpConnection->isConnected()) {
die("Cannot connect to the broker, exiting !\n");
}
return $amqpConnection;
}
function amqp_receive($exchangeName, $routingKey, $queueName) {
$amqpConnection = amqp_connection();
$channel = new AMQPChannel($amqpConnection);
$queue = new AMQPQueue($channel);
$queue->setName($queueName);
$queue->bind($exchangeName, $routingKey);
while($message = $queue->get()) {
echo("Message #".$message->getDeliveryTag()." '".$message->getBody()."'");
if($message->isRedelivery()) {
echo("\t(this message has already been delivered)");
}
// just for testing purpose, shows how to manually remove a message from queue
if(rand(0,6) > 4) {
$queue->ack($message->getDeliveryTag());
echo("\t(this message has been removed from the queue)");
}
print_r($message->getMessageId());
echo "\n";
}
if(!$amqpConnection->disconnect()) {
throw new Exception("Could not disconnect !");
}
}
function amqp_send($text, $routingKey, $exchangeName){
$amqpConnection = amqp_connection();
$channel = new AMQPChannel($amqpConnection);
$exchange = new AMQPExchange($channel);
$exchange->setName($exchangeName);
$exchange->setType("fanout");
$message = $exchange->publish($text, $routingKey);
if(!$message) {
echo "Error: Message '".$message."' was not sent.\n";
} else {
echo "Message '".$message."' sent.\n";
}
if (!$amqpConnection->disconnect()) {
throw new Exception("Could not disconnect !");
}
}
// lets send a message with a "random" content (the date)
amqp_send("Message added at this date: ".date(DATE_RFC822), "action", "amq.fanout");
// you need to sleep for 1 sec if you want to be able to receive the message you just sent ("limitation" must be on the broker side)
sleep(1);
// now we receive messages from the queue we just sent a message on
amqp_receive("amq.fanout","action","action");
Expected result:
----------------
There should not be any memory leak
Actual result:
--------------
A memory leak appears
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 17:00:01 2025 UTC |
I confirm that the memory leak issue is still present in version 1.0.9 running on PHP 5.4.10, see the output of the script : Message '1' sent. [Sat Dec 29 12:45:03 2012] Script: '/usr/local/src/amqp-1.0.9/test.php' /usr/local/src/amqp-1.0.9/amqp_connection.c(465) : Freeing 0x1131A70D8 (6 bytes), script=/usr/local/src/amqp-1.0.9/test.php Last leak repeated 1 time [Sat Dec 29 12:45:03 2012] Script: '/usr/local/src/amqp-1.0.9/test.php' /usr/local/src/amqp-1.0.9/amqp_connection.c(483) : Freeing 0x1131A7E28 (6 bytes), script=/usr/local/src/amqp-1.0.9/test.php Last leak repeated 1 time [Sat Dec 29 12:45:03 2012] Script: '/usr/local/src/amqp-1.0.9/test.php' /usr/local/src/amqp-1.0.9/amqp_connection.c(517) : Freeing 0x110D97280 (2 bytes), script=/usr/local/src/amqp-1.0.9/test.php Last leak repeated 1 time === Total 6 memory leaks detected === result of php --ri amqp : amqp Version => 1.0.9 Revision => $Revision: 327551 $ Compiled => Dec 29 2012 @ 12:43:57 AMQP protocol version => 0-9-1 librabbitmq version => 0.0.1 Directive => Local Value => Master Value amqp.host => localhost => localhost amqp.vhost => / => / amqp.port => 5672 => 5672 amqp.timeout => 0 => 0 amqp.login => guest => guest amqp.password => guest => guest amqp.auto_ack => 0 => 0 amqp.prefetch_count => 3 => 3 result of php - v : PHP 5.4.10 (cli) (built: Dec 26 2012 12:18:20) (DEBUG) Copyright (c) 1997-2012 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans To reproduce, please be sure to compile PHP with the --enable-debug flag