php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27598 list() array key assignment causes HUGE memory leak
Submitted: 2004-03-14 17:48 UTC Modified: 2005-06-03 15:57 UTC
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: lf at burntmail dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 5CVS-2005-04-30 OS: *
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: lf at burntmail dot com
New email:
PHP Version: OS:

 

 [2004-03-14 17:48 UTC] lf at burntmail dot com
Description:
------------
When using array keys as variables in the list() function  there is a noticiable memory leak.

It doesn't seem to matter if you assign values to the array key's before using them in the array.



Reproduce code:
---------------
//memory leak!
while (1)
{
 $out = array(); 
 $arr = array('a','b','c');
 list($out['a'], $out['b'], $out['c']) = $arr;
}

//NO memory leak!!
while (1)
{
 $out = array(); 
   $a = &$out['a'];
   $b = &$out['b'];
   $c = &$out['c'];

 $arr = array('a','b','c');
 list($a, $b, $c) = $arr;
}

Expected result:
----------------
Output every 4000 loops
#  | Memory usage

4000  |  68 KB
8000  |  68 KB
12000  |  68 KB
16000  |  68 KB
20000  |  68 KB
24000  |  68 KB
28000  |  68 KB
32000  |  68 KB
36000  |  68 KB
40000  |  68 KB
44000  |  68 KB
48000  |  68 KB
52000  |  68 KB
56000  |  68 KB
60000  |  68 KB
64000  |  68 KB
68000  |  68 KB
72000  |  68 KB
76000  |  68 KB
80000  |  68 KB
84000  |  68 KB
88000  |  68 KB
92000  |  68 KB
96000  |  68 KB
100000  |  68 KB
104000  |  68 KB
108000  |  68 KB
112000  |  68 KB




Actual result:
--------------
Output  every 4000 loops
# | Memory usage

4000  |  349 KB
8000  |  630 KB
12000  |  911 KB
16000  |  1.2 MB
20000  |  1.4 MB
24000  |  1.7 MB
28000  |  2.0 MB
32000  |  2.3 MB
36000  |  2.5 MB
40000  |  2.8 MB
44000  |  3.1 MB
48000  |  3.4 MB
52000  |  3.6 MB
56000  |  3.9 MB
60000  |  4.2 MB
64000  |  4.5 MB
68000  |  4.7 MB
72000  |  5.0 MB
76000  |  5.3 MB
80000  |  5.6 MB
84000  |  5.8 MB
88000  |  6.1 MB
92000  |  6.4 MB
96000  |  6.7 MB
100000  |  6.9 MB
104000  |  7.2 MB
108000  |  7.5 MB
112000  |  7.8 MB


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-15 08:54 UTC] sniper@php.net
Does not leak at all with PHP_4_3 branch.

 [2005-06-03 15:57 UTC] dmitry@php.net
Fixed in CVS HEAD and PHP_5_0
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Apr 02 10:01:30 2025 UTC