From: phpbug at phormix dot com Operating system: Debian Gnu/Linux PHP version: 4.4.0 PHP Bug Type: Strings related Bug description: str_replace leaks when replacing text in arrays
Description: ------------ Replacing items in an array of 20-30 items with str_replace seems to leak memory. The application in question would crash when parsing various larger CSV files, using upwards to >500MB per an 18MB data-file. Jumps in memory usage were observed at the point where str_replace was run. Using the function 'preg_replace' instead issued no such leak Reproduce code: --------------- str_replace('~comma~', ',', $myarray ); Expected result: ---------------- (values of ~comma~ in string were replaced with actual commas) Actual result: -------------- Progress would end indicating in logs that the memory limit of 500MB (as indicated in php.ini) was exceeded. -- Edit bug report at http://bugs.php.net/?id=34222&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34222&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=34222&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=34222&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=34222&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=34222&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=34222&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=34222&r=needscript Try newer version: http://bugs.php.net/fix.php?id=34222&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=34222&r=support Expected behavior: http://bugs.php.net/fix.php?id=34222&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=34222&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=34222&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=34222&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34222&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=34222&r=dst IIS Stability: http://bugs.php.net/fix.php?id=34222&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=34222&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=34222&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=34222&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=34222&r=mysqlcfg