Bug #74072 [Com]: Memory leaks with setter causing out of memory
| From: | ealexs at gmail dot com | Date: | Thu, 16 Feb 2017 13:25:10 +0000 |
| Subject: | Bug #74072 [Com]: Memory leaks with setter causing out of memory | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-207411@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74072&edit=1
ID: 74072
Comment by: ealexs at gmail dot com
Reported by: ealexs at gmail dot com
Summary: Memory leaks with setter causing out of memory
Status: Duplicate
Type: Bug
Package: Reproducible crash
Operating System: Debian 8
PHP Version: 7.0.15
Block user comment: N
Private report: N
New Comment:
Thank you very much all your points were useful.
I think this should be added to the php docs as "Caution": "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."
> also add $a->__set('x') -> $a->__set('y') - unbounded memory
> growth
Suggested pages:
http://php.net/manual/en/language.oop5.magic.php
http://php.net/manual/en/language.oop5.overloading.php
Previous Comments:
------------------------------------------------------------------------
[2017-02-16 12:57:24] nikic@php.net
On the limitations, quoting from the other bug report:
> 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.
It is not possible to apply this change to PHP 7.0.
As to the jumping memory usage between cycles, this is an artifact of passing "true" to
memory_get_usage(). If you do so, you will see internal details of the allocator. In this case, what
you observe is that when the memory limit is reached, an allocator GC is triggered, which may
release chunks, thus reducing memory usage below the previous value. Generally, I'd recommend
calling memory_get_usage() without argument, as the values become much harder to interpret
otherwise.
------------------------------------------------------------------------
[2017-02-16 12:30:51] ealexs at gmail dot com
@torben - less memory usage without XDEBUG, reduce memory or increase the cycles.
@nikic
Will the fix be applied for PHP 7.0.* also ?
Can you explain a bit the limitations of the fix ?
Why is the memory usage random between the cycles random ? (this worries me a bit)
------------------------------------------------------------------------
[2017-02-16 11:35:27] nikic@php.net
Duplicate of bug #65340.
------------------------------------------------------------------------
[2017-02-16 11:22:55] torben at dannhauer dot info
I can reproduce this bug with the below test script.
I have a error in a production server which seems to be the same but I'm not sure.
On my side, your testscript also fails with xdebug modul loaded, however my production error does
disappear with Xdebug module loaded.
------------------------------------------------------------------------
[2017-02-16 07:53:24] ealexs at gmail dot com
updated the "Package"
------------------------------------------------------------------------
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=74072
--
Edit this bug report at https://bugs.php.net/bug.php?id=74072&edit=1