Bug #81117 [NEW]: Single gc_collect_cycles call does not free objects released in __destruct
From: m at m dot cz
Operating system: any
PHP version: 7.4.20
Package: Scripting Engine problem
Bug Type: Bug
Bug description:Single gc_collect_cycles call does not free objects released in __destruct
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 bug report at https://bugs.php.net/bug.php?id=81117&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81117&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81117&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81117&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81117&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81117&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81117&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81117&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81117&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81117&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81117&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81117&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81117&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81117&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81117&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81117&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81117&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81117&r=mysqlcfg
Thread (2 messages)
- m at m dot cz