From:             mb at diderot dot de
Operating system: Linux
PHP version:      4.3.6
PHP Bug Type:     Session related
Bug description:  readfile + session_start results in huge memory consumption

Description:
------------
When using readfile or fread in combination with 
session_start php seems to allocate memory for the whole 
filesize. Without session_start it doesn't. 
 
Replacing readfile by a fread loop doesn't make any 
difference. 
 

Reproduce code:
---------------
<?php
 //error appears:
 session_start();
 readfile('big.zip'); //big.zip > memory_limit
?>

<?php
 //working fine:
 readfile('big.zip'); //big.zip > memory_limit
?>

<?php
  //fread version, same error
  session_start();
  $fp = fopen('big.zip');
  while($d = fread($fp,4096)) {
    echo $d;
    flush();
  }
?>

Expected result:
----------------
Memory consumation should stay much bellow the whole 
filesize as it does without sessions. 

Actual result:
--------------
apache error.log: 
Allowed memory size of 16777216 bytes exhausted (tried to 
allocate 138188800 bytes) 

-- 
Edit bug report at http://bugs.php.net/?id=28260&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28260&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28260&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28260&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28260&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28260&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28260&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28260&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28260&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28260&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28260&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28260&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28260&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28260&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28260&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28260&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28260&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28260&r=float

Reply via email to