php.net |  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: m at m dot cz
New email:
PHP Version: OS:

 

 [2021-06-09 10:03 UTC] m at m dot cz
Description:
------------
see https://3v4l.org/BeuOd

issue present since PHP 7.4, but not documented in https://github.com/php/php-src/blob/PHP-7.4/NEWS nor UPGRADING

minimalistic test script below should be part of php core test

Test script:
---------------
<?php

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;
gc_collect_cycles();
var_dump(memory_get_usage()- $zeroMemory);

Expected result:
----------------
int(0)

Actual result:
--------------
int(480)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-09 10:36 UTC] cmb@php.net
-Status: Open +Status: Duplicate -Assigned To: +Assigned To: cmb
 [2021-06-09 10:36 UTC] cmb@php.net
Duplicate of bug #78933.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jan 25 23:01:30 2025 UTC