php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53980 On the Windows-version of PHP can not allocate more memory than 512 memory_limi
Submitted: 2011-02-10 11:04 UTC Modified: 2021-02-01 15:53 UTC
Votes:22
Avg. Score:4.7 ± 0.6
Reproduced:19 of 19 (100.0%)
Same Version:15 (78.9%)
Same OS:15 (78.9%)
From: skibi82 at interia dot pl Assigned: cmb (profile)
Status: Not a bug Package: PHP options/info functions
PHP Version: 5.3.9 OS: Win7 , WinXP, Win2008 srv R2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: skibi82 at interia dot pl
New email:
PHP Version: OS:

 

 [2011-02-10 11:04 UTC] skibi82 at interia dot pl
Description:
------------
Fatal error: Out of memory (allocated 537919488) (tried to allocate 536870913 
bytes) XXXX
zend_mm_heap corrupted

The error occurs regardless of the setting memory_limit


Test script:
---------------
<?php
 ini_set ('memory_limit', '4024M');
 echo 'Limit:'.ini_get ('memory_limit')."\n";

$mb='';
$x=0;
do {
$x++;
$mb.='X';
}while ($x< 1048576);
echo "100\n";
$x=0;
$mb100='';
do {
$x++;
$mb100.=$mb;
}while ($x< 100);
echo "1000\n";
$x=0;
$gb='';
do {
$x++;
$gb.=$mb100;
}while ($x< 10);
echo "OK\n";

Expected result:
----------------
Limit4024M
100
1000
OK

Actual result:
--------------
Limit4024M
100
1000
PHP Fatal error:  Out of memory (allocated 631504896) (tried to allocate 6291456
01 bytes) in D:\fortigate\phc-win-1\dupa.php on line 23

Fatal error: Out of memory (allocated 631504896) (tried to allocate 629145601 by
tes) in D:\fortigate\phc-win-1\dupa.php on line 23
zend_mm_heap corrupted

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-11 22:13 UTC] felipe@php.net
-Package: Systems problem +Package: PHP options/info functions
 [2011-03-11 23:33 UTC] amarasatish at gmail dot com
I am having a php file which parses the meta tags out of the html report files and display them in a table. Until now it has wroked fine on PHP 5.2.4.4, now after installing the version 5.3.5, the page doesn't load and give an error:

"PHP Fatal error:  Out of memory (allocated xxxxxx) (tried to allocate xxxxxx
01 bytes) in File on line xx.". I start increasing the memory allocation in php.ini almost upto 1000MB, but still the same error.

If i downgrade to PHP 5.2.4.4, its working again. What could the problem be?

For some reason, the Test Script given here, gives the same error message on version PHP 5.3.5, 5.2.4.4, 4.
 [2011-11-04 12:14 UTC] shaun at laughey dot com
I can confirm the issue affects PHP 5.3.3 on Windows 2008 and 5.3.5 on Windows 7.

I have tested on Ubuntu with 5.3.2 and 5.3.5 and the bug is not present and the script works.
 [2011-11-04 15:40 UTC] pajoye@php.net
Please try with 5.3.8
 [2011-11-04 15:40 UTC] pajoye@php.net
-Status: Open +Status: Feedback
 [2011-11-04 15:54 UTC] skibi8 at interia dot pl
In version 5.3.8 error still occurs

E:\SVN>test.php
5.3.8
Limit:4024M
100
1000
PHP Fatal error:  Out of memory (allocated 736362496) (tried to allocate 734003
01 bytes) in E:\SVN\test.php on line 25

---
echo phpversion()."\n"; 

 ini_set ('memory_limit', '4024M');
 echo 'Limit:'.ini_get ('memory_limit')."\n";

$mb='';
$x=0;
do {
$x++;
$mb.='X';
}while ($x< 1048576);
echo "100\n";
$x=0;
$mb100='';
do {
$x++;
$mb100.=$mb;
}while ($x< 100);
echo "1000\n";
$x=0;
$gb='';
do {
$x++;
$gb.=$mb100;
}while ($x< 10);
echo "OK\n";



Fatal error: Out of memory (allocated 736362496) (tried to allocate 734003201 b
tes) in E:\SVN\test.php on line 25
zend_mm_heap corrupted
 [2012-01-24 18:45 UTC] skibi82 at interia dot pl
-Status: Feedback +Status: Open
 [2012-01-24 18:45 UTC] skibi82 at interia dot pl
Fatal error: Out of memory (allocated 537919488) (tried to allocate 536870913 
bytes) XXXX
zend_mm_heap corrupted

The error occurs regardless of the setting memory_limit
 [2012-01-24 18:47 UTC] skibi82 at interia dot pl
The error still occurs
 [2012-01-24 18:47 UTC] skibi82 at interia dot pl
-Operating System: Windows XP SP3 +Operating System: Win7 , WinXP, Win2008 srv R2 -PHP Version: 5.3.5 +PHP Version: 5.3.9
 [2012-03-06 11:51 UTC] shaun at laughey dot com
Still an issue on PHP 5.3.10 tested on Windows 2008 and Windows 7 using FCGI and mod_php on both platforms.
 [2012-11-04 14:00 UTC] miau dot jp at gmail dot com
This is caused by heap size limitation of Windows. A process can use
heap up to nealy 1500MB on recent versions of Windows.

Because of fragmentation, actual limit is less than 1500MB.
For example, I added some debugging code to PHP (see
https://gist.github.com/4011991 ) and ran following sample
script.

----

<?php
ini_set('memory_limit', '3072M');
define('MB', 1024 * 1024);
$str = str_repeat('a', 400 * MB);
$str = '' . $str;
$str .= $str;

>php bug53980.php
[alloc]        segment: 0x02CF0048-0x02D30047 size: 262144 (0MB)
[free]         segment: 0x02CF0048
[alloc]        segment: 0x02CF0048-0x02D30047 size: 262144 (0MB)
[alloc]        segment: 0x02D30050-0x02D7004F size: 262144 (0MB)
[alloc]        segment: 0x102A0020-0x292E001F size: 419692544 (400MB)
[alloc]        segment: 0x292F0020-0x4233001F size: 419692544 (400MB)
[free]         segment: 0x102A0020
[realloc from] segment: 0x292F0020
[realloc to]   segment: 0x00000000-0x3203FFFF size: 839122944 (800MB)

Fatal error: Out of memory (allocated 420216832) (tried to allocate 838860801 
bytes) in C:\***\bug55980.php on line 6
zend_mm_heap corrupted

----

Dispite the heap has nearly 1100MB free space in total, there is no
contiguous 800MB space. Then HeapRealloc() fails and returns NULL.
 [2021-02-01 15:53 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-02-01 15:53 UTC] cmb@php.net
Prior to PHP 7.0.0, official non-experimental PHP builds for
Windows were only available for x86 which is 32bit even on 64bit
Windows versions, where the address space of a single process is
limited to at most 2GB (or 3GB with 4GT), and in practice, heap
space is way more limited.  As of PHP 7.0.0, official
non-experimental x64 PHP builds for Windows are available; use
these!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC