Bug #81027 [NEW]: WeakReference will cause memory leaks

From: Date: Mon, 10 May 2021 14:04:46 +0000
Subject: Bug #81027 [NEW]: WeakReference will cause memory leaks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233762@lists.php.net to get a copy of this message
From:             gy dot dlcs at gmail dot com
Operating system: Linux
PHP version:      8.0.6
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:WeakReference will cause memory leaks 

Description:
------------
Just like the test script, When you Uncomment the !$wr->get(); line,
You will see the memory leaks in a few seconds.

Test script:
---------------
<?php
ini_set('memory_limit', '16M');

while (true) {
    $a = new stdClass();
    $a->a = $a;

    $wr = WeakReference::create($a);
    unset($a);

    // Uncomment next line, memory will not leak
    // $wr->get();

    // Uncomment next line, memory will leak
    // !$wr->get();
}


Expected result:
----------------
PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried
to allocate 20480 bytes) in test.php on line 9



-- 
Edit bug report at https://bugs.php.net/bug.php?id=81027&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81027&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81027&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81027&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81027&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81027&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81027&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81027&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81027&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81027&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81027&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81027&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81027&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81027&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81027&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81027&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81027&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81027&r=mysqlcfg


Thread (14 messages)

« previous php.bugs (#233762) next »