Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.3.0

Bug #16975 Slow memory leak
Submitted: 2010-01-06 22:28 UTC
From: glub Assigned:
Status: Open Package: Services_Amazon_SQS (version 0.3.0)
PHP Version: 5.2.5 OS: Ubuntu
Roadmaps: (Not assigned)    
Subscription  


 [2010-01-06 22:28 UTC] glub (Gary Cohen)
Description: ------------ I've written a PHP daemon in which a call is made to $queue->retrieve every 10 seconds. I'm seeing the memory usage increase by around 10 bytes after every call. After 12 hours of running the memory usage is around 35 MB. Test script: --------------- <?php require_once 'Services/Amazon/SQS/Exceptions.php'; require_once 'Services/Amazon/SQS/Queue.php'; $access_key = "<access key>"; $secret_access_key = "<secret key>"; $queue_url = 'http://queue.amazonaws.com/<id>'; while ( true ) { $queue = new Services_Amazon_SQS_Queue( $queue_url, $access_key, $secret_access_key ); $messages = $queue->receive( 1, 7200 ); if ( count ($messages) <= 0 ) { echo "no messages\n"; } unset( $queue ); sleep( 10 ); } ?> Expected result: ---------------- No memory leaks.

Comments

 [2010-01-07 00:08 UTC] gauthierm (Michael Gauthier)
Thanks for the bug report. I have a couple of questions to help me test and debug this. 1. Is the queue actually full, are you receiving a message for each call? 1. What size are the messages in the queue? In 12 hours, the script would make 4320 calls. If the script is leaking 10 bytes a call, that would mean 42.2 KB in 12 hours. The majority of the 35 MB of memory is likely allocated on startup. Before the 0.3.0 release, I tested SQS running in a loop receiving 50,000 messages. While there was some leakage, the amount did not grow dangerously over the lifetime of the script.
 [2010-01-07 00:13 UTC] glub (Gary Cohen)
Agreed, if only 10 bytes every 10 seconds it wouldn't be growing to 35MB, so somewhere in the 12 hours it's jumping more. In this test, the queue is empty. I'm just polling it for messages (which are usually very small, around a few bytes). For the test, you can leave the queue empty and watch the memory grow after each receive. I'm also seeing this in 0.2.0
 [2011-12-31 09:32 UTC] gauthierm (Michael Gauthier)
Is this still an issue with newer versions of PHP that include garbage collection? I don't think it is an issue with this package specifically.