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

If it was performing malloc/memcpy/free, in that order, then it would
be freeing the memory back via the free() system call.  Even if it's a
bogus test, it's a test to fit your requirements.  Can you please
clarify how the session saving is taking more than 3 times the memory
usage the script says it's using?


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

[2007-01-24 21:32:34] [EMAIL PROTECTED]

Right, serializing is expected to consume even more memory, because it
has to run malloc/memcpy/free a lot.
Storing 256Mb in session is noway a real task and quite a bad test,
because it's not really clear what you're testing and what result you
want to get.

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

[2007-01-24 21:29:35] tdondich at groundworkopensource dot com

UPDATE:

Modified the script:
<?php

session_start();
$myarray = array();

$numOfIterations = 1000000;
for($counter = 0; $counter < $numOfIterations; $counter++) {
  $myarray[$counter] =
'jkdfjklsdfjklfsdhjklsdfhildfnifsdnsdfnlfsdnklfsdnkglgfnkl;nmklsdf';
}

$_SESSION['test'] = $myarray;

print("SLEEPING<br />");
print("USAGE: " . memory_get_usage());
sleep(5);
?>

I receive this output:
SLEEPING
USAGE: 160289476
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to
allocate 18874411 bytes) in Unknown on line 0

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

[2007-01-24 21:26:56] tdondich at groundworkopensource dot com

I get this output with fatal error:
Fatal error: Allowed memory size of 536870912 bytes exhausted (tried to
allocate 18874411 bytes) in Unknown on line 0

With this script:
<?php

session_start();
$myarray = array();

$numOfIterations = 1000000;
for($counter = 0; $counter < $numOfIterations; $counter++) {
  $myarray[$counter] =
'jkdfjklsdfjklfsdhjklsdfhildfnifsdnsdfnlfsdnklfsdnkglgfnkl;nmklsdf';
}

$_SESSION['test'] = $myarray;

print("SLEEPING<br />");
sleep(5);
?>


Because you get the SLEEPING output, it appears the high memory
consumption is occurring when the script has finished, possibly when
the session is trying to be serialized.

I'm running with PHP Version 5.2.1RC4-dev

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

[2007-01-24 21:18:27] [EMAIL PROTECTED]

Cannot reproduce.

100000 - 25.6Mb
1000000 - 256Mb

Use memory_get_usage() to get the memory usage.

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

[2007-01-24 20:58:37] tdondich at groundworkopensource dot com

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.

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/40222

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

Reply via email to