From:             
Operating system: Centos5
PHP version:      5.3.8
Package:          amqp
Bug Type:         Bug
Bug description:Consuming large amounts of memory

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 bug report at https://bugs.php.net/bug.php?id=60141&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60141&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60141&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60141&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60141&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60141&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60141&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60141&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60141&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60141&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60141&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60141&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60141&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60141&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60141&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60141&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60141&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60141&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60141&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60141&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60141&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60141&r=mysqlcfg

Reply via email to