php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32403 PHP does not free memory, occupied by cross-referencing objects
Submitted: 2005-03-21 22:41 UTC Modified: 2005-04-02 01:00 UTC
Votes:7
Avg. Score:5.0 ± 0.0
Reproduced:6 of 7 (85.7%)
Same Version:3 (50.0%)
Same OS:5 (83.3%)
From: valyala at tut dot by Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.x OS: any
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-03-21 22:41 UTC] valyala at tut dot by
Description:
------------
See reproducible code below


Reproduce code:
---------------
<?

/**
    cross-referencing memory leak.
    PHP garbage collector doesn't free memory for 
    cross-referencing objects. It could be great
    problem for daemons or services, written on PHP
*/
function memleak($size)
{
    $a = str_repeat('a', $size);
    // construct child
    $child = array(
        'data' => $a,
    );
    // construct parent
    $parent = array(
        'data' => $a,
        'child' => &$child,
    );
    // comment following line to prevent memleak
    $child['parent'] = &$parent;
}

// try to leak of 1GB memory
for ($i = 0; $i < 1000; $i++) memleak(1000000);

sleep(10);

?>

Expected result:
----------------
normal execution of script

Actual result:
--------------
PHP occupies all available memory.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-25 02:01 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

As you were very clever and left all the PHP version information open (there is no such PHP version as 'Irrelevant'), we now have no idea on what version you experienced this with first. So try the snapshot.

 [2005-04-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 09:01:31 2024 UTC