php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #80135 Memory leak - some data structure is not shrunk
Submitted: 2020-09-22 17:28 UTC Modified: 2020-09-22 18:21 UTC
From: mvorisek at mvorisek dot cz Assigned:
Status: Duplicate Package: Scripting Engine problem
PHP Version: 7.4.10 OS: any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mvorisek at mvorisek dot cz
New email:
PHP Version: OS:

 

 [2020-09-22 17:28 UTC] mvorisek at mvorisek dot cz
Description:
------------
see test script, there is some zval/GC data structure, that is currently not shrunk

this is an issue for workers that normally process small and large requests occasionally, as once the data structure inside php engine is enlarged, it never goes back and memory per worker/process stays allocated

Test script:
---------------
function createGraph($c) {
    $objs = [];
    for ($i = 0; $i < $c; $i++) {
        $obj = new \stdClass();
        $objs[] = $obj;
        $obj->x = $objs[mt_rand(0, count($objs) - 1)];
    }
}

for ($i = 0; $i < 5; $i++) {
    createGraph(2 * 1000 * 1000);
    
    gc_collect_cycles();
    echo round(memory_get_usage() / (1024 * 1024), 3) . " MiB\n";
}

Expected result:
----------------
memory usage stays below 1 MiB

Actual result:
--------------
16.361 MiB
16.361 MiB
16.361 MiB
16.361 MiB
16.361 MiB

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-22 18:21 UTC] nikic@php.net
-Status: Open +Status: Duplicate
 [2020-09-22 18:21 UTC] nikic@php.net
Duplicate of bug #33487.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jun 19 16:01:23 2021 UTC