From: antoine dot bajolet at tdf dot fr Operating system: Linux 2.4.29 PHP version: 4.3.10 PHP Bug Type: HTTP related Bug description: memory leak in fopen wrappers ?
Description: ------------ It seems that there is a memory leak in fopen wrappers to HTTP. With a minimal compilation of PHP : ./configure --disable-all --enable-sockets --without-pear --enable-memory-limit --without-pcre-regex --without-mysql And the first code above, the memory used increased continuously. (the -n flag is used to ignore any php.ini script. All parameters are default). #sapi/cli/php -n script1.php 12160 13536 13672 13736 13800 13864 13928 13992 14056 14120 14184 ... still increasing With a classic fopen, works fine #sapi/cli/php -n script2.php 12128 12320 12336 12336 12336 12336 12336 12336 12336 12336 12336 ... still stable This is very annoying because we are writing a small php daemon using periodics requests on HTTP hosts. For more infos : #ldd sapi/cli/php libcrypt.so.1 => /lib/libcrypt.so.1 (0x4001b000) libresolv.so.2 => /lib/libresolv.so.2 (0x40049000) libm.so.6 => /lib/i686/libm.so.6 (0x4005b000) libdl.so.2 => /lib/libdl.so.2 (0x4007d000) libnsl.so.1 => /lib/libnsl.so.1 (0x40081000) libc.so.6 => /lib/i686/libc.so.6 (0x40096000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) /lib/libcrypt.so.1 -> libcrypt-2.3.2.so /lib/libresolv.so.2 -> libresolv-2.3.2.so Regards Antoine Bajolet Reproduce code: --------------- With this, memory problem : <?php /* script1.php */ while(true){ echo memory_get_usage()."\n"; $handler = fopen('http://some.thing/','r'); fclose($handler); sleep(2); } // while ?> With this, no memory problem <?php /* script2.php */ while(true){ echo memory_get_usage()."\n"; $handler = fopen('/etc/hosts','r'); fclose($handler); sleep(2); } // while ?> Expected result: ---------------- The memory used has to be stable, not increasing. -- Edit bug report at http://bugs.php.net/?id=32255&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32255&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32255&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32255&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=32255&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=32255&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=32255&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=32255&r=needscript Try newer version: http://bugs.php.net/fix.php?id=32255&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=32255&r=support Expected behavior: http://bugs.php.net/fix.php?id=32255&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=32255&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=32255&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=32255&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32255&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=32255&r=dst IIS Stability: http://bugs.php.net/fix.php?id=32255&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=32255&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=32255&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=32255&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=32255&r=mysqlcfg