Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116909 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 81434 invoked from network); 22 Jan 2022 17:10:24 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 22 Jan 2022 17:10:24 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ED2A11804DF for ; Sat, 22 Jan 2022 10:22:06 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS8560 212.227.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 22 Jan 2022 10:22:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1642875724; bh=ua//NwwnvtZ1rpr92IHM+rlSmQ22SZQlZp22uJw+APk=; h=X-UI-Sender-Class:Date:Subject:To:References:From:In-Reply-To; b=Eaj6Pda17Pyp66wuiMBZA3hEJepylCLy8yLDGyxk+kINJFiNC9u71j3zrlX7DZvY3 dRbFPUUSroRB4f4N4OJXo13LOh/3OIvgBIGRkJhTUkRCjZGlJQ+ygM56rKuUUOOHm4 8Xjva4a60npcUzx5p4/Md9hxxVRcHnbFKYcT3KUY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.2.130] ([84.179.224.47]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbRfv-1maLNV0XfN-00bpfe; Sat, 22 Jan 2022 19:22:04 +0100 Message-ID: <7b6441c4-e095-b196-bc6c-9c0f728f0436@gmx.de> Date: Sat, 22 Jan 2022 19:22:03 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: de-DE To: Rowan Tommins , internals@lists.php.net References: <7ea94d3b-7f1f-b604-b94a-781e0b992c69@gmx.de> <0bcb3e32-9afe-8957-7aa8-ea70f4308407@gmail.com> In-Reply-To: <0bcb3e32-9afe-8957-7aa8-ea70f4308407@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:SD2myJ/o54spS3Tpmcs61tibmgij0dSY5VRElv0SkLk+kSldgjn Ulqem9MaiiMoeC4Iyca/tcSg95uemFijnjwbe9wH/4SOVfpBG3ByG0nf4GYBiC40PeipPiY XJYkckP5opiojuDDyX3R1sB3sg+uvpaLUxCaOmV1/4NCNUsIyXbL/8Z3Ojoj8EJUHt19+jV tUb0w/k7lEF8Tk3aChUfQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:IKz7g3dxeZc=:qfaVnF2W952vYQFWQvv3OD 3/ws8Oh3Hgdaj6p4ABuyCtkIv0xOlMYl7IrlwN3qRzZl3NTNstjNXG93oniWTNVCz/1X9rf38 NYhnE28ZFQSrxcCUFrYkHTUcIuh0tYJUBkynzyzOGojOjQlZp9O+6rT3PArekdq8wUweaMOgs gNYk9LLat0phNrBKEUZGCcXvpcg9iqDUWTxRbpYSMhtZ/eLhVgOQaDyb46zxTdMSBa0xk2lGw EbMg4RB1mrGk9cWtue2MidiGaEY2Kcwuw7nsWbJnZNZZpDbm26tcX7kClY0wzVriMDnp8Pb9W Ti9HZgYyzVyczmISdoXzlDzIFChu/6GCN691EdiWtq6792+bdThg9i5XshbHMOvEGg5PwzDEK 88aQ9RI2viKbFRgoVGHoAnUDOLNt6OVMEuTbuyL4e6vdNutUZUDV78vlpMMwPdE4dYXBWkxCK tSp63d8MG1XP0NYyhQ6ReJG/q1dc7CkEOj8oj3T/+JDPZGAidzEn3rCuArJ9cQuuGQNgc3Al/ QAlId+aH28q/mTnSJZrAYYtn+W0VRMujWAQGh+f/J5z8HIhIkkAjjTfIKgWprVcwTFBkvVldx cPuFV0n5ZOLDJXeRmGufx4j/jYuxfOtUwQqpH7K+2QN25InHDpl7I5vgALS3aslIiRzVQZ85V a5PFDhnKFaG++XgUjz39w9ZHMG4bfqHDmYO/01O6nOMmEMpJdea87pa/Sk19Ft9y/eXafZ02O 6mzCFcBszRGmvIsz1ZLANsdnh8dOO1Aw1AeO7KjsNdk51WiEw4nAVWXp5Bsp7izIpOYDe5gN5 M4BEGXzl/Xnywoy6tU4xV4logo0fymRUp0uas/lWgud7SmrNs1knvpBBNZAp8u1OoBdi2tZtz 8LHj+5KWLx3qhQaP/s3w3MvIF2wrKFGu3ycsBCKvs3j6U5cFBOunLI8egqxGVpoC8HquNd696 ZBCMEV5QRmPDON5Cy0ou2HP+igRV0OSAIh/FrRkJTRv50nWyeL9oJp7ghzDwhLvpCYlbbD4Wh K1K0/IKQIh/dwSYCeL5ZOiwu6xrmMRUDjk4sjOwt/YUDojSHFY72Zzjc4r5c8d/KFmiKLTQ+r qGBlYFamXLyFKs= Subject: Re: [PHP-DEV] Re: Weak Closures From: cmbecker69@gmx.de ("Christoph M. Becker") On 22.01.2022 at 17:18, Rowan Tommins wrote: > On 22/01/2022 15:30, Christoph M. Becker wrote: > >> If you trigger the garbage collector manually (i.e. call >> gc_collect_cycles() after unset($callback)), the loop terminates right >> away.=C2=A0 I'm not sure why it doesn't without manually triggering the= GC. > > Most values are freed as soon as their refcount reaches zero, which > obviously won't happen for circular references, so an additional > algorithm is needed for those. This "cycle collection" algorithm is > relatively expensive, so doesn't run every time a possible candidate is > found, but only when a list of candidates reaches a particular > threshold. The algorithm is outlined in the manual, although it looks > like the constant 10000 mentioned there has been replaced by an adaptive > threshold (which can be inspected with gc_status()): > https://www.php.net/manual/en/features.gc.collecting-cycles.php > > If you measure memory usage while running the example code in a loop, > you should see it slowly growing and then periodically dropping each > time a cycle collection is run. That's why gc_collect_cycles() exists - > if you _know_ you've created circular references, you can tell the > engine to find and free them immediately, rather than waiting for the > next pass. Ah, right. Thanks Rowan! Christoph