> 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 < 1000000; $i++) {
        $object = new class {};

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

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 code should
only ever create a single class in memory, right? Why the leak with eval()?

> $class = get_class($obj);
> $obj = new $class;

Interesting. Can this behaviour be relied upon (is it documented?), or is
this an implementation detail that may change at any time?

Thank you,
Ben

Reply via email to