#29668 [Opn->Bgs]: Memory leak when looping an associative array
| From: | iliaa@php.net | Date: | Mon, 16 Aug 2004 22:20:54 +0000 |
| Subject: | #29668 [Opn->Bgs]: Memory leak when looping an associative array | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-64731@lists.php.net to get a copy of this message | ||
ID: 29668
Updated by: iliaa@php.net
Reported By: thecanadiancrappler at hotmail dot com
-Status: Open
+Status: Bogus
Bug Type: Reproducible crash
Operating System: Windows XP SP 1
PHP Version: 4.3.8
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Each time you do $array[$i] you add a new value to the
array. The loop goes on forever since each time the size of
the array being calculated, move count($array) outside the
loop.
Previous Comments:
------------------------------------------------------------------------
[2004-08-14 02:17:10] thecanadiancrappler at hotmail dot com
Description:
------------
When looping numerically through an associative array, certain
operations cause a massive memory leak in Apache, eating up all
available ram at about 60mb/s. Windows grinds to a halt as 1gb of
Virtual Memory is gobbled up.
Trying to echo each element of the array returns nothing as would be
expected, but concatting or executing a function such a stripslashes on
the elements causes the memory leak.
My php.ini differs only in max_execution time and the maximum size of
POST uploads.
Reproduce code:
---------------
$array['a'] = 'Some text';
$array['b'] = "It\'s nice text";
// prints 2
echo count($array);
// prints nothing
echo $array[0];
// does nothing
$array[0] = stripslashes($array[0]);
for ($i=0; $i<count($array); $i++)
{
// does nothing
echo $array[$i];
// memory leak
$array[$i] = 'blah' . $array[$i];
// memory leak
$array[$i] = stripslashes($array[$i]);
}
Expected result:
----------------
To have no effect on the array
Actual result:
--------------
Sorry, I can't decipher your instructions for using backtrace! Shoot
the stupid guy ;o)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29668&edit=1