ID: 40222 Updated by: [EMAIL PROTECTED] Reported By: tdondich at groundworkopensource dot com -Status: Open +Status: Bogus Bug Type: Apache2 related Operating System: Ubuntu Edgy PHP Version: 5.2.0 New Comment:
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. Previous Comments: ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ [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. ------------------------------------------------------------------------ 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