|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81117 Single gc_collect_cycles call does not free objects released in __destruct
Submitted: 2021-06-09 10:03 UTC Modified: 2021-06-09 10:36 UTC
From: m at m dot cz Assigned: cmb (profile)
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.4.20 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
38 + 14 = ?
Subscribe to this entry?

 [2021-06-09 10:03 UTC] m at m dot cz

issue present since PHP 7.4, but not documented in nor UPGRADING

minimalistic test script below should be part of php core test

Test script:

class X {
    public $r;
    public $r2;
    public function __destruct() {
        $this->r2 = null;

function getCircle() {
    $a = new X();
    $b = new X();
    $c = new X();
    $a->r = $c;
    $b->r = $a;
    $c->r = $b;
    return $a;

$zeroMemory = memory_get_usage();

$u = getCircle();
$u->r2 = getCircle();
$u = null;
var_dump(memory_get_usage()- $zeroMemory);

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-09 10:36 UTC]
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-06-09 10:36 UTC]
Duplicate of bug #78933.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Oct 22 15:03:39 2021 UTC