From: wojtek at wojjie dot com
Operating system: Gentoo/Fedora
PHP version: 5.0.5
PHP Bug Type: Performance problem
Bug description: fread() allocates length bytes without releasing unneeded
Description:
------------
fread() seems to allocate length amount of memory for getting data from
the connection, but does not release it till you do something to variable.
If $dat did have data, and you did:
$dat=$dat.'';
It would then release any unused memory.
Not sure if this is a bug, but I thought I would submit it incase.
Reproduce code:
---------------
<?php
$fp=fsockopen('udp://192.168.0.1', 27015, $errno, $errstr);
stream_set_blocking($fp, false);
$dat=fread($fp, 4096000);
fclose($fp);
$bmem=memory_get_usage();
echo strlen($dat)."\n";
unset($dat);
echo (memory_get_usage()-$bmem)."\n";
?>
Expected result:
----------------
Difference in memory usage should not be so huge as 4095896 bytes.
Actual result:
--------------
-4095896
--
Edit bug report at http://bugs.php.net/?id=34471&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34471&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34471&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34471&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34471&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34471&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34471&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34471&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34471&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34471&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34471&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34471&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34471&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34471&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34471&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34471&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34471&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34471&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34471&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34471&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34471&r=mysqlcfg