Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126695 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id AD0841A00BC for ; Mon, 10 Mar 2025 16:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741624009; bh=Pc9Rw1/jzGGlLX8jOY5YuIm96LI3uNEQE92ZHjBXPHw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=m2vQ3dBitDhTvRTJEvDqOlxJUumhWInpZKqwTJtP5NRNXJtdfjdtvM4wY5ruHL8uh KH2G/n1BQAOXVBYq14io9mhq2EhdtqBK9xALEQkcDGBBephxhdP43dkf4OJ3Md2XsS tlT0o9TCmBjZnJapvo4cXJ7cIJIExcVNbA65pHVmOiOJlFnEHJd2QVfge4aQroFAIJ LTbQlc5+kfBJheQEZHyViukttL0Xti79fCqGYlu7XpTKTWCqZ95xtRrrng22E26k4N vX8NaJKz8yI77uYw2g3wF6qsnzCLT+FnXY2GXPTf/l1McomfOeMLrM0iTt43Vgp2bR X4TfKIykMq6sQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6C67A180037 for ; Mon, 10 Mar 2025 16:26:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 10 Mar 2025 16:26:48 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-e60b75f8723so3094332276.0 for ; Mon, 10 Mar 2025 09:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741624162; x=1742228962; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Pc9Rw1/jzGGlLX8jOY5YuIm96LI3uNEQE92ZHjBXPHw=; b=lK+abwR+xKqZXz784MO/NFfHa+pqY4kCUDjDlmFprrDOins/thRhv11qDQlM9c4cMp 5c2Bqy7ilNLrCt2qq3/+kjKT5bacnD5rvpzJ8sKW2puZw2jyV3D//suN53y62h2Rklr8 g3AmX76pdKDgT7h2W+oKev0EWCHnmc9dIze4/dhZPT0FvWYs4BEkhh0gmwUT0PNrwZYp XZ4zTpMIudJ643NUF0xvEJtb3gbS4xibvgj5AiSdZOo8TxHzVsVUmy434Ka+xY8UWHgn Q1hMwT9CPHz7aJICConusS/YKkXhIPl9jxUmwzww8/UxJ32TG8e6GYtnNKAd4f6PoLQG WoVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741624162; x=1742228962; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Pc9Rw1/jzGGlLX8jOY5YuIm96LI3uNEQE92ZHjBXPHw=; b=cHxyyYGycAjXmC4geQN5pRlyslGNLxtwNuQ3aM2CcNzuJkI8aC75GqxLPKLc2BCoA7 Cw0/doC/wY3kWGIpgOzgv75rtOQVpEB67uLvPCieoiTEFpiu2FcW2DcrlroyGzgtty6h Mq2qO6Vn6f8n+k7JO9vlPsrY7L+YpTq8AFrihmu2iFXcfpTI9F5KOAZsD5PjTzQCr7eP 3JwUp9xD+8rBL5XJ+PkCxoDBfGDaqWRWx+HFbOiKYxGfz2V8ekCDFwH7a6r8uYPjkaBa 6mN8iNPwRGOPn9CnF5XYrAlqye2o0ORGcIoAqJilyaNQWAhvA+wWktQhOZyLqDGFh+bA kSrw== X-Gm-Message-State: AOJu0Ywuvi8g+RvPD1fARKxkCEGGRzU9WKALR1GaxQq70ntM9l4C5LnN 1RAavirosu+VX3xflYBnAYq782EoA3XrLPbow28Pga6EyK7pNQlbHJnjS/2UMAgYxWiRy82aHr4 IJ7I7KhdtS+iekqdlM0YhqOe2TaU= X-Gm-Gg: ASbGncuBLKlwhABlcjVhwMtbK8lbxhoT6yecIaoAVILFem8zrqhNyLbQNl6SFYE+1VP W/OSM42GgbE0YK85kW3IdA3I3h9gH7w2qlbGTmusNLfenRDpGLI9d/ltiMCyiHV6ja3Tz4Di67R 3qFFpujPknVpm+dTw+5kz2H21nBQ== X-Google-Smtp-Source: AGHT+IHhEkYPFLQuXVO5dOIcDDd0JVeOQYrvLPtbnfSZEO0h6U7aBozFF3Ku3RWECCvvcdRN1R+cMvnNgJsMmatMWRA= X-Received: by 2002:a05:6902:200d:b0:e60:a3c1:6ed3 with SMTP id 3f1490d57ef6-e635c16cf69mr19678619276.21.1741624161859; Mon, 10 Mar 2025 09:29:21 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 10 Mar 2025 18:29:11 +0200 X-Gm-Features: AQ5f1JqfFFvEB33AzwRkFUZZizE1B4TolDKkMmd_9FGcZxdKjDAurqc7SNe1ihY Message-ID: Subject: Re: [PHP-DEV] Manual unset and GC To: Vinicius Dias Cc: PHP internals Content-Type: multipart/alternative; boundary="000000000000800728062fff7990" From: edmond.ht@gmail.com (Edmond Dantes) --000000000000800728062fff7990 Content-Type: text/plain; charset="UTF-8" Hello! In modern PHP, the garbage collector (GC) is not a mandatory component, provided that the code is written without circular dependencies. As soon as an object loses its last reference (i.e., its reference count reaches zero), PHP immediately frees the resources. In this sense, you can think of PHP as similar to C++. Assigning NULL to a variable is essentially an explicit destruction of the reference. This can be useful in some cases, such as in a long-running application where the function scope will not be exited for a long time. However, in typical scenarios, it only clutters the code with an unnecessary instruction. --- Ed. --000000000000800728062fff7990 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello!

In modern PHP, the garbage co= llector (GC) is not a mandatory component, provided that the code is writte= n without circular dependencies. As soon as an object loses its last refere= nce (i.e., its reference count reaches zero), PHP immediately frees the res= ources. In this sense, you can think of PHP as similar to C++.

Assigning NULL to a variable is essentially an explicit des= truction of the reference. This can be useful in some cases, such as in a l= ong-running application where the function scope will not be exited for a l= ong time. However, in typical scenarios, it only clutters the code with an = unnecessary instruction.

---

Ed.

--000000000000800728062fff7990--