Quoting Andrew Morgan <[EMAIL PROTECTED]>:

> That was easy!
>
> I added some simple debug statements to print out the memory usage  
> at various steps in imp/lib/Folder.php.  I printed out the memory  
> usage after each message was retrieved inside the 'for' loop, at the  
> end of the loop, and after the str_replace.  Here were my results:

[snip]

> I'm almost positive that the memory usage doubles temporarily for  
> this function call:
>
>           $body = str_replace("\r\n", "\n", $body);
>
> However, I was able to avoid this memory usage penalty by calling  
> str_replace within the loop on each message, rather than the entire  
> huge string at the end.  This also uses less memory overall.  I  
> suspect that PHP memory routines don't "cleanup" memory very well  
> when the size of a variable is reduced as it is in the str_replace()  
> call above.
>
> I've attached a patch which implements this change.

Excellent - this is committed to HEAD and FW_3. Thanks for doing the  
legwork and especially for the patch!

> However, it still fails if you try to download a zipped folder.   
> Again, this is probably caused by the temporary need for twice the  
> memory in order to make a working copy of the folder.  Unfortunately  
> I don't see any way around that.

We might be able to use streams or a tempfile to build the zipped  
folder, but I haven't looked into it yet.

Thanks again,
-chuck
-- 
IMP mailing list - Join the hunt: http://horde.org/bounties/#imp
Frequently Asked Questions: http://horde.org/faq/
To unsubscribe, mail: [EMAIL PROTECTED]

Reply via email to