Edit report at https://bugs.php.net/bug.php?id=60141&edit=1
ID: 60141
User updated by: steven_wright at mcafee dot com
Reported by: steven_wright at mcafee dot com
Summary: Consuming large amounts of memory
Status: Open
Type: Bug
Package: amqp
Operating System: Centos5
PHP Version: 5.3.8
Block user comment: N
Private report: N
New Comment:
There is actually only one consumer in the code that I posted. Had to fit it
into
20 lines.
Previous Comments:
------------------------------------------------------------------------
[2011-10-26 15:24:22] steven_wright at mcafee dot com
Description:
------------
amqp 0.3.1 beta
I have a script that runs a loop 10,000 times. In the loop I publish two
messages.
There are two consumers waiting in a while loop that get the messages using
consume().
The script consumes about 10GB of RAM.
I am concerned about the amount of memory being used.
The code that I pasted below should be placed into two separate files. Each one
is
run from the console. Start the consumer first.
Test script:
---------------
$cnnConfig = array("exchange" => "test-topic", "queue" => "test-queue",
"hostname" => "localhost", "options" => array("type" => "topic", "autoDelete"
=> true));
$cnn = new AMQPConnection($cnnConfig);
$cnn->connect();
$logQ = new AMQPQueue($cnn);
$logQ->declare('log');
$logQ->bind($cnnConfig['exchange'], 'log');
$options = array('min' => 1,'max' => 10,'ack' => true);
while (true){$msg = $logQ->consume($options);
var_dump($msg[0]['message_body']); }
// Producer code
$cnnConfig = array("exchange" => "test-topic", "queue" => "test-queue",
"hostname" => "localhost", "options" => array("type" => "topic", "autoDelete"
=> true));
$cnn = new AMQPConnection($cnnConfig);
$cnn->connect();
$ex = new AMQPExchange($cnn, $cnnConfig['exchange']);
$ex->declare($cnnConfig['exchange'], $cnnConfig['options']['type'],
$cnnConfig['options']['autoDelete']);
for ($i = 0; $i < 10000; $i++){
$ex->publish('Message '.$i.' goes to test.log: ' . date("h:i:s"), 'log');
}
Expected result:
----------------
I expect that the script will echo the message 10,000 times.
string(36) "Message 0 goes to test.log: 11:19:04"
string(36) "Message 1 goes to test.log: 11:19:04"
string(37) "Message 2 goes to test.log: 11:19:04"
And so on.
Actual result:
--------------
[swright@vm1-centos5 rabbitmq]$ php rabbit-cons.php
string(36) "Message 0 goes to test.log: 11:19:04"
string(36) "Message 1 goes to test.log: 11:19:04"
string(37) "Message 11 goes to test.log: 11:19:04"
Killed
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60141&edit=1