From: rodricg at sellingsource dot com Operating system: Linux PHP version: 5.3.0RC2 PHP Bug Type: Scripting Engine problem Bug description: __call performs extra allocs
Description: ------------ When returning a value from __call (as compared to a non-dynamic method) extra memory is allocated. This leads to performance degradation dependent on the size of the returned value. Hopefully this is a better description/example of bug #47525. Reproduce code: --------------- http://rodric.org/mem.phps This script takes 3 arguments. ie. mem.php <iterations> <method> <size> See "Actual Result" for invocations. Expected result: ---------------- Bytes allocated when using __call should be similar to not using __call. When using __call the time taken should not degrade linearly as the size of the result value increases. Actual result: -------------- Change USE_ZEND_ALLOC to 1 and you will see that "magic" performs exactly <iterations> more allocs than "getStr". Using __call: USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100 magic 1000000 2>&1 | pcregrep "Time|allocs" Time: 1.5781 ==25158== malloc/free: 19,564 allocs, 18,033 frees, 104,476,083 bytes allocated. USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100 magic 2000000 2>&1 | pcregrep "Time|allocs" Time: 3.1066 ==25161== malloc/free: 19,564 allocs, 18,033 frees, 205,476,083 bytes allocated. Not Using __call: USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100 getStr 1000000 2>&1 | pcregrep "Time|allocs" Time: 0.0280 ==25181== malloc/free: 18,764 allocs, 17,233 frees, 4,444,183 bytes allocated. USE_ZEND_ALLOC=0 valgrind php -n -d memory_limit=1024M mem.php 100 getStr 2000000 2>&1 | pcregrep "Time|allocs" Time: 0.0281 ==25183== malloc/free: 18,764 allocs, 17,233 frees, 5,444,183 bytes allocated. -- Edit bug report at http://bugs.php.net/?id=48197&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48197&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48197&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48197&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48197&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48197&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48197&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48197&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48197&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48197&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48197&r=support Expected behavior: http://bugs.php.net/fix.php?id=48197&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48197&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48197&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48197&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48197&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48197&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48197&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48197&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48197&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48197&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48197&r=mysqlcfg