Hi internals,

I've tracked down a memory leak to an anonymous class created within eval():

```
for ($i = 0; $i < 1000000; $i++) {
        $object = eval('return new class {};');

        if ($i % 1000 == 0) {
                echo memory_get_usage() . "\n";
        }
}

```

The memory usage quickly ramps up and memory_limit is reached in seconds.
Without eval(), the memory usage stays flat. I'm on 7.3.6.

*Is this a bug?* Or is this some inherent limitation of eval() that cannot
be fixed?

Thanks for any insight.
Ben

*In case you're wondering (I'm sure you are!), I need this to dynamically
create an object that implements an arbitrary number of interfaces
<https://github.com/brick/schema/blob/master/src/ObjectFactory.php>, for a
schema.org <http://schema.org> structured data reader library.*

Reply via email to