Bug #65340 [Csd]: Memory leak when using magic __set ?
Edit report at https://bugs.php.net/bug.php?id=65340&edit=1
ID: 65340
Updated by: nikic@php.net
Reported by: vitalif at mail dot ru
Summary: Memory leak when using magic __set ?
Status: Closed
Type: Bug
Package: Class/Object related
Operating System: Linux
PHP Version: 5.5.1
Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
@ealexs: A magic accessor should not trigger a magic accessor on a different property name on the
same object. $a->__get('x') -> $a->__set('x') is fine.
$a->__get('x') -> $b->__get('y') is fine. $a->__get('x')
-> $a->__get('y') may still lead to unbounded memory growth, if this is done for
many distinct property names.
Previous Comments:
------------------------------------------------------------------------
[2017-02-16 12:25:35] ealexs at gmail dot com
Can you please explain: "no recursion over different property names".
You mean the magic setter should not trigger another magic setter ? Would this apply on the object
itself ($this) or it can also affect other objects ?
Thanks, Alex
------------------------------------------------------------------------
[2017-02-16 11:35:27] nikic@php.net
Related To: Bug #74072
------------------------------------------------------------------------
[2017-02-16 11:35:02] nikic@php.net
This issue has been fixed in PHP 7.1. Memory usage should now be constant for typical uses (no
recursion over different property names) of magic getters/setters.
------------------------------------------------------------------------
[2015-08-28 21:30:14] vitalif at mail dot ru
But of course it's still a bug? :)
------------------------------------------------------------------------
[2015-08-28 21:21:18] nikic@php.net
The reason for this are property recursion guards. In PHP 5 32bit these take 72 bytes per distinct
property name that was used with __get/etc. so in this case it would be 72*500000 bytes, which
matches your numbers.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=65340
--
Edit this bug report at https://bugs.php.net/bug.php?id=65340&edit=1
Thread (10 messages)