Bug #81117 [Opn->Dup]: Single gc_collect_cycles call does not free objects released in __destruct

From: Date: Wed, 09 Jun 2021 10:36:28 +0000
Subject: Bug #81117 [Opn->Dup]: Single gc_collect_cycles call does not free objects released in __destruct
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-234280@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81117&edit=1

 ID:                 81117
 Updated by:         cmb@php.net
 Reported by:        m at m dot cz
 Summary:            Single gc_collect_cycles call does not free objects
                     released in __destruct
-Status:             Open
+Status:             Duplicate
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   any
 PHP Version:        7.4.20
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Duplicate of bug #78933.


Previous Comments:
------------------------------------------------------------------------
[2021-06-09 10:03:05] 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)


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81117&edit=1


Thread (2 messages)

« previous php.bugs (#234280) next »