|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: m at m dot cz
New email:
PHP Version: OS:


 [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-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 17:01:31 2024 UTC