ID: 29838 Updated by: [EMAIL PROTECTED] Reported By: tim at digicol dot de -Status: Open +Status: Bogus Bug Type: Strings related Operating System: SuSE Linux 8.2 (i586) PHP Version: 4.3.8 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation 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 You created 100000 temporary variables inside PHP, what do you expect... Previous Comments: ------------------------------------------------------------------------ [2004-08-25 17:27:44] tim at digicol dot de Also happens on PHP 4.3.9RC1 ... ------------------------------------------------------------------------ [2004-08-25 17:15:04] tim at digicol dot de Description: ------------ Using argument swapping in sprintf() or printf() calls makes PHP leak memory. (I've been running this code using the PHP CLI binary.) Have been able to reproduce this with PHP 4.3.7 as well. ./configure --with-config-file-path=/usr/local/php/conf --enable-cli --enable-track-vars --disable-magic-quotes --enable-xml --enable-sysvsem --enable-sysvshm --with-apxs=/usr/local/apache/bin/apxs --disable-debug --enable-ftp --enable-wddx --enable-sigchild --enable-inline-optimization --enable-exif --with-pgsql=/usr/local/pgsql --prefix=/usr/local/php --with-oci8=/dot/oracle/product/9.2.0 --with-db3=/usr/local/db3 --with-zlib --with-dom --with-gd --with-mhash=/usr/local/mhash --enable-mbstring=all --enable-mbstr-enc-trans --enable-mbregex --disable-pic --with-gdbm --enable-pcntl --enable-sysvmsg --with-iconv=/dot/local/iconv --enable-memory-limit Reproduce code: --------------- <?php $b = memory_get_usage(); $location = "zoo"; $num = 2; // No memory leak: // $format = "The %s contains %s monkeys\n"; // Memory leak: $format = "The %2\$s contains %1\$d monkeys\n"; for ($i = 1; $i <= 100000; $i++) sprintf($format, $num, $location); echo "Grown by " . (memory_get_usage() - $b) . "\n"; ?> Expected result: ---------------- Grown by 376 Actual result: -------------- Grown by 4000336 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=29838&edit=1
