php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47000 imap_body() and imap_savebody() memory leak.
Submitted: 2009-01-04 21:31 UTC Modified: 2009-04-30 20:27 UTC
From: alan at binarystars dot com Assigned: pajoye (profile)
Status: Not a bug Package: IMAP related
PHP Version: 5.2.8 OS: 2.6.25-14.fc9.i686
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alan at binarystars dot com
New email:
PHP Version: OS:

 

 [2009-01-04 21:31 UTC] alan at binarystars dot com
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.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-05 16:01 UTC] iliaa@php.net
Can you run it via valgrind rather then php's memory checker? I suspect 
the issue is just some temp vars that will be cleaned up by garbage 
collection.
 [2009-01-05 17:17 UTC] alan at binarystars dot com
iliaa at php.net, 
Give me a moment to update. Thanks.
 [2009-01-13 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2009-04-30 20:27 UTC] pajoye@php.net
Duplicate of #47940, which is now fixed in cvs (all active branches).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC