June 30, 2019 10:43 AM
> To: Benjamin Morel ; Nikita Popov
>
> Cc: CHU Zhaowei ; PHP Internals
> Subject: Re: [PHP-DEV] Memory leak in eval()'d code
>
> Hi!
>
> > I still don't understand *why*, then, the memory stays flat when the
> > new class does not ha
Hi!
> I still don't understand *why*, then, the memory stays flat when the new
> class does not happen in eval():
Because that code creates only one class.
> I checked get_class() for all instances returned, **it's always the same
> class name whether it's called from eval() or not**, so this co
>
> What is the "non scaled case"? To repeat what I said earlier: Without eval
> there is no and will not be a leak.
> The bug is that eval() currently reuses an existing class instead of
> creating a new one each time. Calling get_class(eval("return new class
> {};")) should be returning a new str
On Sat, Jun 29, 2019 at 11:56 PM David Walker wrote:
>
>
> On Sat, Jun 29, 2019 at 15:52 Nikita Popov wrote:
>
>> On Sat, Jun 29, 2019 at 11:25 PM Benjamin Morel > >
>> wrote:
>>
>> The leaked memory is an allocated but unused class
>> entry. We could plug that particular leak -- but I should e
On Sat, Jun 29, 2019 at 15:52 Nikita Popov wrote:
> On Sat, Jun 29, 2019 at 11:25 PM Benjamin Morel
> wrote:
>
> The leaked memory is an allocated but unused class
> entry. We could plug that particular leak -- but I should emphasize that
> the current behavior is incorrect and once the key col
On Sat, Jun 29, 2019 at 11:25 PM Benjamin Morel
wrote:
> > The problem here is that OP is *creating* many classes (the fact that
> they are anonymous ultimately doesn't matter) by eval'ing code. That is
> what causes the leak.
>
> I still don't understand why there is no leak when *not* using eva
> The problem here is that OP is *creating* many classes (the fact that
they are anonymous ultimately doesn't matter) by eval'ing code. That is
what causes the leak.
I still don't understand why there is no leak when *not* using eval(),
though.
Ben
ita Popov
> *Sent:* Saturday, June 29, 2019 3:58 PM
> *To:* CHU Zhaowei
> *Cc:* Stanislav Malyshev ; Benjamin Morel <
> benjamin.mo...@gmail.com>; PHP Internals
> *Subject:* Re: [PHP-DEV] Memory leak in eval()'d code
>
>
>
> On Sat, Jun 29, 2019 at 9:07 AM CH
Sent: Saturday, June 29, 2019 3:58 PM
To: CHU Zhaowei
Cc: Stanislav Malyshev ; Benjamin Morel
; PHP Internals
Subject: Re: [PHP-DEV] Memory leak in eval()'d code
On Sat, Jun 29, 2019 at 9:07 AM CHU Zhaowei mailto:m...@jhdxr.com> > wrote:
I think we missed the point here.
> As Johannes already pointed out, we cannot garbage collect anonymous
class definitions due to the existence of opaque references.
I still don't understand *why*, then, the memory stays flat when the new
class does not happen in eval():
```
for ($i = 0; $i < 100; $i++) {
$object = ne
9, 2019 6:52 AM
> > To: Benjamin Morel
> > Cc: PHP Internals
> > Subject: Re: [PHP-DEV] Memory leak in eval()'d code
> >
> >
> >
> > On 6/28/19 3:37 PM, Benjamin Morel wrote:
> > > That's not a "leak". You create new objects (i
Internals
> Subject: Re: [PHP-DEV] Memory leak in eval()'d code
>
>
>
> On 6/28/19 3:37 PM, Benjamin Morel wrote:
> > That's not a "leak". You create new objects (in this case, classes),
> > they take memory.
> >
> >
> >
On 6/28/19 3:37 PM, Benjamin Morel wrote:
> That's not a "leak". You create new objects (in this case, classes),
> they take memory.
>
>
> Why do they not "leak" memory without eval() then? Replace with `$object
> = new class {};` and memory usage stays flat.
> There has do be some kin
>
> That's not a "leak". You create new objects (in this case, classes),
> they take memory.
Why do they not "leak" memory without eval() then? Replace with `$object =
new class {};` and memory usage stays flat.
There has do be some kind of garbage collection for these anonymous classes.
Ben
Hi!
> I case this is non-trivial to fix. Each invocation recompile a new
> piece of code, which creates a new class.
That's not a "leak". You create new objects (in this case, classes),
they take memory.
--
Stas Malyshev
smalys...@gmail.com
--
PHP Internals - PHP Runtime Development Mailing L
On June 28, 2019 6:49:49 PM GMT+02:00, Benjamin Morel
wrote:
>
>> or unload the class once
>> it's not needed anymore (which is hard to detect with reflection and
>> other mechanisms which aren't bound to an instance's zval and also
>not
>> cheap)
>
>AFAIK, unloading a class is not possible fr
> Theoretical it is thinkable we could either detect equal classes (but
> unlikely to happen ... if it's the same why do it in eval, zthus cost
> likely is higher than benefit in most cases?)
Thanks for your reply. I do it in eval() because schema.org has many types
(more than 600 at the moment),
On Fri, 2019-06-28 at 02:41 +0200, Benjamin Morel wrote:
> Hi internals,
>
> I've tracked down a memory leak to an anonymous class created within
> eval():
>
> ```
> for ($i = 0; $i < 100; $i++) {
> $object = eval('return new class {};');
>
> if ($i % 1000 == 0) {
>
Hi internals,
I've tracked down a memory leak to an anonymous class created within eval():
```
for ($i = 0; $i < 100; $i++) {
$object = eval('return new class {};');
if ($i % 1000 == 0) {
echo memory_get_usage() . "\n";
}
}
```
The memory usage quick
19 matches
Mail list logo