[imp] Cannot download large folder
Chuck Hagenbuch
chuck at horde.org
Wed Jul 18 19:56:43 UTC 2007
Quoting Andrew Morgan <morgan at orst.edu>:
> 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
More information about the imp
mailing list