#32318 [Opn->Fbk]: memory_limit does not work
ID: 32318
Updated by: sniper@php.net
Reported By: camka at email dot ee
-Status: Open
+Status: Feedback
-Bug Type: *General Issues
+Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 4.3.10
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php4-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php4-win32-STABLE-latest.zip
This works fine here..
Previous Comments:
------------------------------------------------------------------------
[2005-03-15 17:33:31] camka at email dot ee
Description:
------------
php compiled with --enable-memory-limit, but setting the value of
memory_limit more then certain number won't affect scripts.
tried set the value of memory_limit in both php.ini and script body -
nothing helped.
Reproduce code:
---------------
<?php
echo ini_get('memory_limit'),"\n";
ini_set('memory_limit', 100000000);
echo ini_get('memory_limit'),"\n";
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);
function a()
{
echo 'fck oyu!';
}
register_shutdown_function('a');
$zz = 'u';
for($i=1; $i<1000; $i++)
{
$zz .= $zz;
echo $i,' - ', memory_get_usage(),"<br>\n";flush();
}
?>
Expected result:
----------------
allocate at least 100MB of memory and die if exceeded.
Actual result:
--------------
100M
100000000
1 - 12912<br>
2 - 12912<br>
3 - 12920<br>
4 - 12944<br>
5 - 12960<br>
6 - 13032<br>
7 - 13096<br>
8 - 13224<br>
9 - 13480<br>
10 - 13992<br>
11 - 15016<br>
12 - 17064<br>
13 - 21160<br>
14 - 29352<br>
15 - 45736<br>
16 - 78504<br>
17 - 144040<br>
18 - 275112<br>
19 - 537256<br>
20 - 1061544<br>
21 - 2110120<br>
22 - 4207272<br>
23 - 8401576<br>
error_log:
FATAL: erealloc(): Unable to allocate 16777217 bytes
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32318&edit=1
Thread (2 messages)