ID:               40222
 User updated by:  tdondich at groundworkopensource dot com
 Reported By:      tdondich at groundworkopensource dot com
-Status:           Closed
+Status:           Open
 Bug Type:         Apache2 related
 Operating System: Ubuntu Edgy
 PHP Version:      5.2.0
 New Comment:

Update.  I am still running 5.2-latest, however, I changed the script
to have numOfIterations be equal to 1000000.  The script began the old
behavior of ballooning and trying to consume as much memory as possible
and the system started swapping and becoming unresponsive.

With 1000000 elements, the memory requirements should still be around:

1000000 X 66 = 66000000bytes = 62megabytes

The array is copied twice, and that should be 124megs.  We're
continuing to see memory consumption skyrocket and consume all memory.

This does not occur when the number of elements is 100000.


Previous Comments:
------------------------------------------------------------------------

[2007-01-24 19:02:24] [EMAIL PROTECTED]

>1) Can we know what was the cause of the issue in case we
> need to do a work around?
I can't tell that having just the information you've provided.

>2) When is PHP 5.2.1 scheduled to be released?
Soon. RC3 is expected to be the last release candidate.

------------------------------------------------------------------------

[2007-01-24 18:58:11] tdondich at groundworkopensource dot com

PHP Version 5.2.1RC4-dev,  php5.2-200701241730

Corrects the issue.

2 things:

1) Can we know what was the cause of the issue in case we need to do a
work around?

2) When is PHP 5.2.1 scheduled to be released?

------------------------------------------------------------------------

[2007-01-24 18:43:37] [EMAIL PROTECTED]

Please try using this CVS snapshot:

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



------------------------------------------------------------------------

[2007-01-24 18:42:09] tdondich at groundworkopensource dot com

Description:
------------
Using:
- Apache 2.2.4
- PHP 5.2.0 w/ sessions

Description:
When running this simple script, Apache2 will consume all available
memory and the script will not complete (with no memory limit and high
time limit) until all memory is taken by Apache 2 process and system
starts to fail (swap extensively until nothing is responsive).


Reproduce code:
---------------
<?php
session_start();
$myarray = array();
$numOfIterations = 100000;  // Set to 10000 to see the script succeed
for($counter = 0; $counter < $numOfIterations; $counter++) {
  $myarray[$counter] =
'jkdfjklsdfjklfsdhjklsdfhildfnifsdnsdfnlfsdnklfsdnkglgfnkl;nmklsdf';
}
// copy the array, just for kicks
$_SESSION['test'] = $myarray;
sleep(5);  // See the memory usage in top for awhile
print("Completed.");
?>


Expected result:
----------------
Apache2 process (pre-fork) will consume all available memory and
continue to climb until system swaps excessively and then becomes
unresponsive.

Changing the $numOfIterations to 10000 causes it to succeed.

By my account, the memory needed approx for each array is:

100000 X 66 = 6600000bytes
6600000 / 1048576 = 6 megabytes

Even when copying it to $_SESSION, it should only take 12 megs, plus
maybe a little more for overhead (array constructs, program execution).
 We're seeing consumption of over a gigabyte and growing with one script
execution.


Actual result:
--------------
TAKEN FROM TOP:
Mem:   1035632k total,  1021568k used,    14064k free,     1208k
buffers
Swap:  3028212k total,   432996k used,  2595216k free,    40336k
cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND   
                                                                       

16094 tdondich  16   0  344m  86m 5172 S    1  8.6  15:16.51 java      
                                                                       

 4205 root      15   0  197m  19m 3960 S    1  1.9  31:37.61 Xorg      
                                                                       

28209 daemon    18   0  779m 704m 2148 D    1 69.7   0:04.34 httpd  

No other pages being served on this box.  The script was continuing to
execute at this time.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40222&edit=1

Reply via email to