|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-04-23 23:46 UTC] webmaster at macway dot com
Description:
------------
Despite proper setting of php.ini memory_limit, and
despite having 2 GB of available ram, a script on
windows server 2000 can't work with more than 64MB in
memory.
There's no problems on a Mac OS X box.
That means you can't process huge volume of data in
arrays for example if the php server is a window 2k box
!
Reproduce code:
---------------
<?php
for ($i = 1; $i <= 1024; $i++) // I'm just making a 1024 Byte string
{
$chunk .='a';
}
for ($i = 1; $i <= 66000; $i++) // I repeat it more than 65535 time and it fails
{
$toto .=$chunk;
}
echo $toto;
?>
Expected result:
----------------
A 65MB string should be returned.
This works perfectly on Mac OS X, but fails on Windows
2000.
Actual result:
--------------
Windows 2000 aborts and return a "document contains no
data".
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 04:00:01 2025 UTC |
Faster code exhibiting the problem : <?php for ($i = 1; $i <= 1024; $i++) // I'm just making a 1024 Byte string { $chunk .='a'; } for ($i = 1; $i <= 66000; $i++) // if you use 65000 it works { $tablo[]=$chunk; } echo "c'est fini"; ?>ah, this bug. It is to do with the COW reference created by the engine when you copy $chunk around. Since it is the same chunk, the engine saves copying the 1MB and adds a reference to the variable. The problem is that ZE1 has a limit of 64k references before it overflows and causes this problem. It has nothing to do with memory usage. It is a known bug in this database (although I couldn't find it just now; it *is* in here somewhere). This problem will not be fixed in PHP 4.x, but has already been addressed in PHP 5. Workaround: use $toto .= str_repeat('a', 1024) inside the main loop, as this returns unique strings on each iteration.