Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106105 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 98033 invoked from network); 29 Jun 2019 09:50:29 -0000 Received: from unknown (HELO smtpbgeu1.qq.com) (52.59.177.22) by pb1.pair.com with SMTP; 29 Jun 2019 09:50:29 -0000 X-QQ-mid:Yeas7t1561792046t964t24022 Received: from 14D73359B2E14ADDB4DDC3857AE32898 (me@jhdxr.com [220.255.44.152]) X-QQ-SSF:00000000000000F0F61000000000000 To: "'Stanislav Malyshev'" , "'Benjamin Morel'" Cc: "'PHP Internals'" References: <8f07c0dc-f9a5-8c76-1d48-0fac762bfc4f@gmail.com> <92dba455-17df-41dd-c523-bb0db3c12078@gmail.com> In-Reply-To: <92dba455-17df-41dd-c523-bb0db3c12078@gmail.com> Date: Sat, 29 Jun 2019 15:07:24 +0800 Message-ID: <003b01d52e49$4db89390$e929bab0$@jhdxr.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Content-Language: zh-cn Thread-Index: AQGNUWw+475Jgca4R2IsmDo72cP1JgLEeVtGApLIHtEBYAxcbACSYCsTpwee+KA= X-QQ-SENDSIZE: 520 Feedback-ID: Yeas:jhdxr.com:qybgforeign:qybgforeign2 X-QQ-Bgrelay: 1 Subject: RE: [PHP-DEV] Memory leak in eval()'d code From: me@jhdxr.com (=?utf-8?b?Q0hVIFpoYW93ZWk=?=) I think we missed the point here. Clousre, or anonymous class, should = not be considered as normal class. We expect normal class existing once = we declare it till end of script. However, for anonymous class, it's = usually used within certain scope, so not only the instances, the class = itself should be included in the GC as well.=20 I guess the problem here is we didn't GC the space for definition of = anonymous classes. Regards, CHU Zhaowei > -----Original Message----- > From: Stanislav Malyshev > Sent: Saturday, June 29, 2019 6:52 AM > To: Benjamin Morel > Cc: PHP Internals > Subject: Re: [PHP-DEV] Memory leak in eval()'d code >=20 >=20 >=20 > 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 =3D new class {};` and memory usage stays flat. > > There has do be some kind of garbage collection for these anonymous = classes. >=20 > 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). >=20 > -- > Stas Malyshev > smalyshev@gmail.com >=20 > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, = visit: > http://www.php.net/unsub.php >=20