From: rodricg at sellingsource dot com Operating system: linux PHP version: 5.2.9 PHP Bug Type: Class/Object related Bug description: value returned from __call copied prematurely
Description: ------------ Values returned from the magic __call method are copied immediately resulting in increased memory usage. Reproduce code: --------------- <?php function mem($msg='') { echo ($msg ? $msg.": " : '').number_format(memory_get_usage(1))."\n"; } class A { public $str; public function __construct() { $this->str = str_repeat("a", 1000000); } public function __call($m, $a) {return $this->str;} public function getStr() {return $this->str;} } $a = new A(); mem('new A()'); $b = $a->str; mem('$a->str'); $c = $a->getStr(); mem('$a->getStr()'); $d = $a->magic(); mem('$a->magic()'); ?> Expected result: ---------------- new A(): 1,310,720 $a->str: 1,310,720 $a->getStr(): 1,310,720 $a->magic(): 1,310,720 Actual result: -------------- new A(): 1,310,720 $a->str: 1,310,720 $a->getStr(): 1,310,720 $a->magic(): 2,359,296 -- Edit bug report at http://bugs.php.net/?id=47525&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47525&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47525&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47525&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47525&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47525&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47525&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47525&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47525&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47525&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47525&r=support Expected behavior: http://bugs.php.net/fix.php?id=47525&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47525&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47525&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47525&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47525&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47525&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47525&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47525&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47525&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47525&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47525&r=mysqlcfg