|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-05-02 03:01 UTC] jani@php.net
[2009-05-04 20:15 UTC] rodricg at sellingsource dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 13:00:01 2025 UTC |
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