[Tickets #5913] Re: Lower memory usage while downloading files

bugs at bugs.horde.org bugs at bugs.horde.org
Tue Dec 11 00:18:51 UTC 2007


DO NOT REPLY TO THIS MESSAGE. THIS EMAIL ADDRESS IS NOT MONITORED.

Ticket URL: http://bugs.horde.org/ticket/?id=5913
-----------------------------------------------------------------------
 Ticket             | 5913
 Updated By         | olger.diekstra at cardno.com.au
 Summary            | Lower memory usage while downloading files
 Queue              | Gollem
 Version            | HEAD
 Type               | Enhancement
 State              | Feedback
 Priority           | 1. Low
 Owners             | Chuck Hagenbuch
-----------------------------------------------------------------------


olger.diekstra at cardno.com.au (2007-12-10 16:18) wrote:

OK, lack of time prevented me from going further on this.
Tried the modifications. It didn't work so I took a look at view.php and
modified it as follows:

case 'download_file':
    $browser->downloadHeaders($filename, null, false,
$GLOBALS['gollem_vfs']->size($filedir, $filename));
    if (is_resource($stream)) {
         while ($buffer = fread($stream, 10240)) { 
           print $buffer;
           ob_flush(); flush();
           usleep(50000);
           }
       } else {
         echo $data; 
       }
     /*  if (is_resource($stream)) { 
        fpassthru($stream);
     } else {
        echo $data;
    }  */
    break;

That works for me with 16MB memory_limit downloading a 61MB file. The
fpassthru still goggles up more memory than is desirable. ob_flush() and
flush() are nessary to clear internals of the webserver and php, the
usleep(50000) (.05 seconds) allows a bit of time for the buffers to be
actually flushed before filling them again.
Hows that?

Cheers! Olger.



More information about the bugs mailing list