#47000 [NEW]: imap_body() and imap_savebody() memory leak.
| From: | alan at binarystars dot com | Date: | Sun, 04 Jan 2009 21:31:09 +0000 |
| Subject: | #47000 [NEW]: imap_body() and imap_savebody() memory leak. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-132542@lists.php.net to get a copy of this message | ||
From: alan at binarystars dot com
Operating system: 2.6.25-14.fc9.i686
PHP version: 5.2.8
PHP Bug Type: IMAP related
Bug description: imap_body() and imap_savebody() memory leak.
Description:
------------
# Problem:
imap_body() and imap_savebody() memory leak. During the following
test of 26 email messages totaling a sum of 244.05Mb it seems you
need TWICE the amount of memory in order to receive the message body
via imap_body(). When using the imap_savebody() func it seems you
need approximately the same amount of memory as the email message
itself. The problem in particular is repeatable in any size email
message... even when you unset the variables/objects returned by the
func. In other words, you want to receive a message body of 5Mb using
imap_body() func; you'll need 10Mb of available free RAM just to
store the message body to a variable. Now, say you receive 10
messages each at 5Mb, and unset all the variables. That would mean
you'll need 100Mb of free memory to read all ten messages. See the
reproduced code and the results for more information.
# Question:
Is there a way to flush the memory without actually exiting out of
the script?
Reproduce code:
---------------
Colorized version:
http://home.binarystars.com/~alan/imap_bug/test.html
(30k)
Text version:
http://home.binarystars.com/~alan/imap_bug/test.txt
(5.3k)
Result of method 1 via imap_body():
http://home.binarystars.com/~alan/imap_bug/method1_results.txt
(3.6k)
Result of method 2 via imap_savebody():
http://home.binarystars.com/~alan/imap_bug/method2_results.txt
Expected result:
----------------
When I run the script I expect it to use less (RSS) resident memory.
Actual result:
--------------
Instead of freeing up memory the script takes up more than Oracle
running five hundred databases.
--
Edit bug report at http://bugs.php.net/?id=47000&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47000&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47000&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47000&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=47000&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47000&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=47000&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=47000&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=47000&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=47000&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=47000&r=support
Expected behavior: http://bugs.php.net/fix.php?id=47000&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=47000&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=47000&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=47000&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47000&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47000&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=47000&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=47000&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=47000&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=47000&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=47000&r=mysqlcfg