Mombu the Php Forum sponsored links

Go Back   Mombu the Php Forum > Php > #31763 : Memory leak on file dowloading when using sessions?
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 8th March 02:10
php-bugs
External User
 
Posts: 1
Default #31763 : Memory leak on file dowloading when using sessions?



From: adyzah at hotmail dot com
Operating system: Linux
PHP version: 4.3.10
PHP Bug Type: Apache related
Bug description: Memory leak on file dowloading when using sessions?

Description:
------------
I am testing the following code that pushes a file to the browser
(Linux + Apache 1.3 + PHP 4.3.10 but tested also under several other
configs)

!!!!!!
Try it with a BIG test1.zip (e.g. 100M in size)

Try it with wget http://server/test.php or a browser but the result is
more accurate when using wget since in browsers could work if you already
had a succesfull download of a smaller file.
!!!!!!

What i discovered is that if i keep the 2 session initialisation
functions
the script will work ONLY if the allocated memory in php.ini is greater
than the size
of the tested file. If i remove the session functions the script works
fine
even if the test1.zip file is very big (hundreds of Megs)

Reproduce code:
---------------
<?php
session_save_path('/tmp');
session_start();
$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName .
"\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));
$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;
?>

Expected result:
----------------
The file should dowload via a browser or via wget

Actual result:
--------------
tail from apache error_log:

Allowed memory size of 12582912 bytes exhausted (tried to allocate 10240
bytes)

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


  sponsored links


2 8th March 02:10
php-bugs
External User
 
Posts: 1
Default #31763 : Memory leak on file dowloading when using sessions?



ID: 31763
User updated by: adyzah at hotmail dot com
Reported By: adyzah at hotmail dot com
-Status: Feedback
+Status: Open
Bug Type: Apache related
Operating System: Linux
PHP Version: 4.3.10
New Comment:

Yes, is set to 1. And indeed if i set it to 0 it works. But i am not
sure if i can set it to 0

Btw: from my observations if i put memory limit 200M and try to
download a 150M file, judging from the delayed response, seems that the
php engine tries to buffer all content, which is abnormal. Session
initialisation should have to affect headers and not content.

Thanks,

Adrian Zaharia


Previous Comments:
------------------------------------------------------------------------

[2005-01-30 17:11:57] iliaa@php.net

Do you have session.use_trans_sid enabled?

------------------------------------------------------------------------

[2005-01-30 12:10:31] adyzah at hotmail dot com

Description:
------------
I am testing the following code that pushes a file to the browser
(Linux + Apache 1.3 + PHP 4.3.10 but tested also under several other
configs)

!!!!!!
Try it with a BIG test1.zip (e.g. 100M in size)

Try it with wget http://server/test.php or a browser but the result is
more accurate when using wget since in browsers could work if you
already had a succesfull download of a smaller file.
!!!!!!

What i discovered is that if i keep the 2 session initialisation
functions
the script will work ONLY if the allocated memory in php.ini is greater
than the size
of the tested file. If i remove the session functions the script works
fine
even if the test1.zip file is very big (hundreds of Megs)

Reproduce code:
---------------
<?php
session_save_path('/tmp');
session_start();
$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName .
"\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));
$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;
?>

Expected result:
----------------
The file should dowload via a browser or via wget

Actual result:
--------------
tail from apache error_log:

Allowed memory size of 12582912 bytes exhausted (tried to allocate
10240 bytes)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31763&edit=1
  Reply With Quote
3 8th March 02:10
External User
 
Posts: 1
Default #31763 : Memory leak on file dowloading when using sessions?


ID: 31763
Updated by: iliaa@php.net
Reported By: adyzah at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Apache related
Operating System: Linux
PHP Version: 4.3.10
New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the do***entation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When that option is turned on the output is being buffered in memory
causing the memory problem you are seeing.


Previous Comments:
------------------------------------------------------------------------

[2005-01-30 18:00:11] adyzah at hotmail dot com

Yes, is set to 1. And indeed if i set it to 0 it works. But i am not
sure if i can set it to 0

Btw: from my observations if i put memory limit 200M and try to
download a 150M file, judging from the delayed response, seems that the
php engine tries to buffer all content, which is abnormal. Session
initialisation should have to affect headers and not content.

Thanks,

Adrian Zaharia

------------------------------------------------------------------------

[2005-01-30 17:11:57] iliaa@php.net

Do you have session.use_trans_sid enabled?

------------------------------------------------------------------------

[2005-01-30 12:10:31] adyzah at hotmail dot com

Description:
------------
I am testing the following code that pushes a file to the browser
(Linux + Apache 1.3 + PHP 4.3.10 but tested also under several other
configs)

!!!!!!
Try it with a BIG test1.zip (e.g. 100M in size)

Try it with wget http://server/test.php or a browser but the result is
more accurate when using wget since in browsers could work if you
already had a succesfull download of a smaller file.
!!!!!!

What i discovered is that if i keep the 2 session initialisation
functions
the script will work ONLY if the allocated memory in php.ini is greater
than the size
of the tested file. If i remove the session functions the script works
fine
even if the test1.zip file is very big (hundreds of Megs)

Reproduce code:
---------------
<?php
session_save_path('/tmp');
session_start();
$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName .
"\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));
$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;
?>

Expected result:
----------------
The file should dowload via a browser or via wget

Actual result:
--------------
tail from apache error_log:

Allowed memory size of 12582912 bytes exhausted (tried to allocate
10240 bytes)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31763&edit=1
  Reply With Quote
4 8th March 02:10
External User
 
Posts: 1
Default #31763 : Memory leak on file dowloading when using sessions?


ID: 31763
Updated by: johannes@php.net
Reported By: adyzah at hotmail dot com
Status: Bogus
Bug Type: Apache related
Operating System: Linux
PHP Version: 4.3.10
New Comment:

When session.use_trans_sid*is on the output is bufferd to
rewrite Links in the content to hold the session id.


Previous Comments:
------------------------------------------------------------------------

[2005-01-30 18:12:27] iliaa@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the do***entation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When that option is turned on the output is being buffered in memory
causing the memory problem you are seeing.

------------------------------------------------------------------------

[2005-01-30 18:00:11] adyzah at hotmail dot com

Yes, is set to 1. And indeed if i set it to 0 it works. But i am not
sure if i can set it to 0

Btw: from my observations if i put memory limit 200M and try to
download a 150M file, judging from the delayed response, seems that the
php engine tries to buffer all content, which is abnormal. Session
initialisation should have to affect headers and not content.

Thanks,

Adrian Zaharia

------------------------------------------------------------------------

[2005-01-30 17:11:57] iliaa@php.net

Do you have session.use_trans_sid enabled?

------------------------------------------------------------------------

[2005-01-30 12:10:31] adyzah at hotmail dot com

Description:
------------
I am testing the following code that pushes a file to the browser
(Linux + Apache 1.3 + PHP 4.3.10 but tested also under several other
configs)

!!!!!!
Try it with a BIG test1.zip (e.g. 100M in size)

Try it with wget http://server/test.php or a browser but the result is
more accurate when using wget since in browsers could work if you
already had a succesfull download of a smaller file.
!!!!!!

What i discovered is that if i keep the 2 session initialisation
functions
the script will work ONLY if the allocated memory in php.ini is greater
than the size
of the tested file. If i remove the session functions the script works
fine
even if the test1.zip file is very big (hundreds of Megs)

Reproduce code:
---------------
<?php
session_save_path('/tmp');
session_start();
$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName .
"\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));
$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;
?>

Expected result:
----------------
The file should dowload via a browser or via wget

Actual result:
--------------
tail from apache error_log:

Allowed memory size of 12582912 bytes exhausted (tried to allocate
10240 bytes)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31763&edit=1
  Reply With Quote
5 8th March 02:10
php-bugs
External User
 
Posts: 1
Default #31763 : Memory leak on file dowloading when using sessions?


ID: 31763
User updated by: adyzah at hotmail dot com
Reported By: adyzah at hotmail dot com
Status: Bogus
Bug Type: Apache related
Operating System: Linux
PHP Version: 4.3.10
New Comment:

Thanks for the info.

However, the ideea of caching all seems a bit risky

Adrian


Previous Comments:
------------------------------------------------------------------------

[2005-01-30 18:13:14] johannes@php.net

When session.use_trans_sid*is on the output is bufferd to
rewrite Links in the content to hold the session id.

------------------------------------------------------------------------

[2005-01-30 18:12:27] iliaa@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the do***entation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

When that option is turned on the output is being buffered in memory
causing the memory problem you are seeing.

------------------------------------------------------------------------

[2005-01-30 18:00:11] adyzah at hotmail dot com

Yes, is set to 1. And indeed if i set it to 0 it works. But i am not
sure if i can set it to 0

Btw: from my observations if i put memory limit 200M and try to
download a 150M file, judging from the delayed response, seems that the
php engine tries to buffer all content, which is abnormal. Session
initialisation should have to affect headers and not content.

Thanks,

Adrian Zaharia

------------------------------------------------------------------------

[2005-01-30 17:11:57] iliaa@php.net

Do you have session.use_trans_sid enabled?

------------------------------------------------------------------------

[2005-01-30 12:10:31] adyzah at hotmail dot com

Description:
------------
I am testing the following code that pushes a file to the browser
(Linux + Apache 1.3 + PHP 4.3.10 but tested also under several other
configs)

!!!!!!
Try it with a BIG test1.zip (e.g. 100M in size)

Try it with wget http://server/test.php or a browser but the result is
more accurate when using wget since in browsers could work if you
already had a succesfull download of a smaller file.
!!!!!!

What i discovered is that if i keep the 2 session initialisation
functions
the script will work ONLY if the allocated memory in php.ini is greater
than the size
of the tested file. If i remove the session functions the script works
fine
even if the test1.zip file is very big (hundreds of Megs)

Reproduce code:
---------------
<?php
session_save_path('/tmp');
session_start();
$sFileName = 'test1.zip';
$sFileDir = '/var/www/html/';
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment;filename=\"" . $sFileName .
"\"");
header("Content-Length: " . filesize($sFileDir . $sFileName));
header('Pragma: cache');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Connection: close');
header('Expires: ' . date('r', time()+60*60));
header('Last-Modified: ' . date('r', time()));
$oFp = fopen($sFileDir . $sFileName, "rb");
$iReadBufferSize = 512;
while (!feof($oFp)) {
echo fread ($oFp, $iReadBufferSize);
}
fclose ($oFp);
exit;
?>

Expected result:
----------------
The file should dowload via a browser or via wget

Actual result:
--------------
tail from apache error_log:

Allowed memory size of 12582912 bytes exhausted (tried to allocate
10240 bytes)


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=31763&edit=1
  Reply With Quote


  sponsored links


Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666