Bug #81117 [Opn->Dup]: Single gc_collect_cycles call does not free objects released in __destruct
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)