Project

General

Profile

Actions

Bug #2083

closed

Excessive Memory usage with streamed files from PHP

Added by eqisow over 15 years ago. Updated almost 9 years ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
ASK QUESTIONS IN Forums:

Description

When downloading a tar archive generated on the fly with the below PHP page lighttpd's memory usage increases dramatically (it gains almost 1MB for every MB downloaded) and the memory isn't released when the download completes. I can confirm this issue in 1.4.19 in Debian Lenny as well as 1.4.23 from Squeeze. I thought it might be an issue with the code, but Apache does not seem to suffer the same problem.

The offending code:

http://codepad.org/JfvSWxcm


Files

download.php (14.5 KB) download.php eqisow, 2009-10-13 06:28

Related issues 1 (0 open1 closed)

Is duplicate of Bug #949: fastcgi, cgi, flush, php5 problem.FixedActions

Added by gstrauss almost 9 years ago

Revision 5a91fd4b (diff)

[core] buffer large responses to tempfiles (fixes #758, fixes #760, fixes #933, fixes #1387, #1283, fixes #2083)

This replaces buffering entire response in memory which might lead to
huge memory footprint and possibly to memory exhaustion.

use tempfiles of fixed size so disk space is freed as each file sent

update callers of http_chunk_append_mem() and http_chunk_append_buffer()
to handle failures when writing to tempfile.

x-ref:
"memory fragmentation leads to high memory usage after peaks"
https://redmine.lighttpd.net/issues/758
"Random crashing on FreeBSD 6.1"
https://redmine.lighttpd.net/issues/760
"lighty should buffer responses (after it grows above certain size) on disk"
https://redmine.lighttpd.net/issues/933
"Memory usage increases when proxy+ssl+large file"
https://redmine.lighttpd.net/issues/1283
"lighttpd+fastcgi memory problem"
https://redmine.lighttpd.net/issues/1387
"Excessive Memory usage with streamed files from PHP"
https://redmine.lighttpd.net/issues/2083

Actions

Also available in: Atom