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
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.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2021 The PHP Group
All rights reserved.
Last updated: Mon Sep 20 03:03:36 2021 UTC