RE: [PHP-DEV] Memory leak in eval()'d code

This is only part of a thread. view whole thread
June 30, 2019 12:48 (=?utf-8?b?Q0hVIFpoYW93ZWk=?=)
Eval is not the only case that will cause memory usage growing actually. is an example using include inside a loop, which is used to simulate including same file several times. I agree it might be trivial to improve for eval since it's not recommended to use due to security concern nowadays. But I think we should pay attention to this issue since include/require behave the same.

In theory, I understand how it happens. You won't be surprised if you copy the code and paste it several times and more memory is used. It's reasonable that more memory is needed to compile longer codes. Include several times just work like copy&paste several times. But since we are including the same file, is it possible to detect and reuse the space?

CHU Zhaowei

> -----Original Message----- > From: Stanislav Malyshev <> > Sent: Sunday, 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 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 code > > should only ever create a single class in memory, right? Why the leak with > eval()? > > There's no leak, eval() just creates new class each time. > -- > Stas Malyshev > > > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: > >