jDownloads

First of all: Thank you for your time. Thanks for trying to help us making jDownloads a better component. It's very much appreciated!

================================================
THIS BUGTRACKER IS CLOSED!!!
THIS BUGTRACKER IS CLOSED!!!
THIS BUGTRACKER IS CLOSED!!!
================================================

So it is not possible to add new task here.
Please use the support forum when you will do this.

We hope we can go online with a new bugtracker site in the next weeks - we work on it.

Many thanks.
Tasklist

FS#134 - jDownloads runs out of memory with large downloads

Attached to Project: jDownloads
Opened by Anonymous Submitter - Tuesday, 31 January 2012, 21:08 GMT+2
Task Type Bug Report
Category Backend / Core
Status Assigned
Assigned To Administrator (admin)
Operating System Joomla 1.6.x
Severity High
Priority Normal
Reported Version 1.8.2
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

When downloading large files (say over 100 MBytes) via PHP script, jDownloads can produce a 0-byte download file. In the server logs, the following message is produced:

[Tue Jan 31 12:51:52 2012] [error] [client 66.238.61.25] PHP Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 155013121 bytes) in /home/public_html/components/com_jdownloads/jdownloads.php on line 734, referer: http://www.yourwebsite.com/downloadingthisfile.html

This problem occurs because jDownloads attempts to read the entire file into memory using @readfile in components/com_jdownloads/jdownloads.php . This will of course exhaust available PHP memory for very large files without reporting an error message, producing a 0-byte download.

Here is a workaround for this problem. In components/com_jdownloads/jdownloads.php, replace the @readfile line with the following code, which reads the downloaded file in 1 MByte chunks.

I am sure that I am not the only person seeing this problem -- many people seem to be having 0 byte downloads, and this is likely the cause and fix.

---- snip

ob_clean();
flush();

// If it's a large file, readfile might not be able to do it in one go, so:
$chunksize = 1 * (1024 * 1024); // how many bytes per chunk
if ($len > $chunksize) {
$handle = fopen($file, 'rb');
$buffer = '';
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
}
fclose($handle);
} else {
@readfile($file);
}

ob_clean();
flush();

---- snip
This task depends upon

Loading...