Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106121 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 96711 invoked from network); 30 Jun 2019 15:31:18 -0000 Received: from unknown (HELO smtpbguseast2.qq.com) (54.204.34.130) by pb1.pair.com with SMTP; 30 Jun 2019 15:31:18 -0000 X-QQ-mid:Yeas8t1561898913t814t10118 Received: from 14D73359B2E14ADDB4DDC3857AE32898 (me@jhdxr.com [220.255.44.152]) X-QQ-SSF:00000000000000F0F61000000000000 To: "'Stanislav Malyshev'" , "'Benjamin Morel'" , "'Nikita Popov'" Cc: "'PHP Internals'" References: <8f07c0dc-f9a5-8c76-1d48-0fac762bfc4f@gmail.com> <92dba455-17df-41dd-c523-bb0db3c12078@gmail.com> <003b01d52e49$4db89390$e929bab0$@jhdxr.com> In-Reply-To: Date: Sun, 30 Jun 2019 20:48:32 +0800 Message-ID: <003201d52f42$1ffbf290$5ff3d7b0$@jhdxr.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQGNUWw+475Jgca4R2IsmDo72cP1JgLEeVtGApLIHtEBYAxcbACSYCsTAiPDS8MApMvubgFLbPVXAVH10Nmm3lgZMA== Content-Language: zh-cn X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:jhdxr.com:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: RE: [PHP-DEV] Memory leak in eval()'d code From: me@jhdxr.com (=?utf-8?b?Q0hVIFpoYW93ZWk=?=) Eval is not the only case that will cause memory usage growing actually. = https://3v4l.org/fPhlU 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? Regards, 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 >=20 > Hi! >=20 > > I still don't understand *why*, then, the memory stays flat when the > > new class does not happen in eval(): >=20 > Because that code creates only one class. >=20 > > 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()? >=20 > There's no leak, eval() just creates new class each time. > -- > Stas Malyshev > smalyshev@gmail.com >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: > http://www.php.net/unsub.php >=20