Re: Memory leak in eval()'d code
| From: | Stanislav Malyshev | Date: | Fri, 28 Jun 2019 22:52:27 +0000 |
| Subject: | Re: Memory leak in eval()'d code | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-106104@lists.php.net to get a copy of this message | ||
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 kind of garbage collection for these anonymous classes.
AFAIR this does not create new classes, since it's the same code, and
same code means same class. But eval() has new code every time, thus new
class. Generally I don't think PHP has any operation that can destroy an
existing class. It won't be easy too since you don't know whether there
are any objects of this class around (unless you're in shutdown).
--
Stas Malyshev
smalyshev@gmail.com