ID:               47940
 Updated by:       [email protected]
 Reported By:      jake dot levitt at mailtrust dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         IMAP related
 Operating System: Ubuntu 8.04 (linux:2.6.24-21)
 PHP Version:      5.2.9
 Assigned To:      pajoye
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2009-04-24 19:56:23] [email protected]

2nd review of cclient, it is wrong to free the body as it is a simple
pointer to the msg data, not a copy of its contents. However the
criteria has to be freed. I'd to revert the fix for fetch_body and looks
for better solution (maybe userland) to minimize the memory usage.

------------------------------------------------------------------------

[2009-04-24 19:01:44] [email protected]

There are also similar bugs with the criteria and other various imap
structure which should be freed as well. fix for the criteria on its
way.

------------------------------------------------------------------------

[2009-04-24 18:52:52] nick at mailtrust dot com

After a little more testing we opened and closed the imap connection
after every 50 messages.  This seems to release the memory and works as
a temporary fix.


Also, we have confirmed the same bug in imap_fetchbody.  I tested
applying the same fix as above and it seems to fix the issue.

------------------------------------------------------------------------

[2009-04-24 17:51:26] [email protected]

Will test it using my test imap server. The last fix is correct but
there is certainly other sources of leaks.

------------------------------------------------------------------------

[2009-04-24 17:47:45] jake dot levitt at mailtrust dot com

Hey guys it looks like we were a little hasty in submitting this patch.
 It now seems that our patch does lessen the memory leak, but does not
eradicate it.  We ran our test script using the patch and it seemed to
work, but running the actual migration program shows that there is still
a leak.  Before our program would migrate ~1.5gb of mail now it migrates
~2.4gb before running out of memory.  We have updated our test script to
better expose the memory leak:

/**
 * To watch memory usage use:
 * ps -eo pid,ppid,rss,vsize,pcpu,pmem,cmd -ww --sort=pid | grep
"\(memory-usage-test\)\|\(PID\)" | grep -v grep
 */
$flags = '/novalidate-cert';
$host = 'a.host.com:143';
$username = '[email protected]';
$password = 'password';
$folder = 'INBOX';

$base_imap_string = '{' . $host . $flags . '}';
$connect_string = $base_imap_string . $folder;

$mailbox = @imap_open($connect_string, $username, $password, 0, 3);
$reopen_success = imap_reopen($mailbox, $connect_string, 0, 3);

$message_ids = imap_search($mailbox, "ALL", SE_UID);
$num_msgs = count($message_ids);
for ($i = 0; $i < 1000000; $i++) {
    $msg_num = $i % $num_msgs;
    imap_body($mailbox, $message_ids[$msg_num], FT_UID);
}

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/47940

-- 
Edit this bug report at http://bugs.php.net/?id=47940&edit=1

Reply via email to