php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54237 Fatal error: Out of memory
Submitted: 2011-03-12 18:18 UTC Modified: 2021-07-14 14:35 UTC
Votes:15
Avg. Score:4.6 ± 0.7
Reproduced:14 of 14 (100.0%)
Same Version:7 (50.0%)
Same OS:7 (50.0%)
From: jsakk at mailmetrash dot com Assigned: cmb (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3.5 OS: Windows 2008 64bit
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jsakk at mailmetrash dot com
New email:
PHP Version: OS:

 

 [2011-03-12 18:18 UTC] jsakk at mailmetrash dot com
Description:
------------
System has 24GB of RAM and 10GB used at time of running
memory_limit = -1 in PHP.INI
Running PHP.EXE on command line
Fatal error: Out of memory (allocated 1993342976) (tried to allocate 162 bytes)
Only able to allocate approx 1901MB

Test script:
---------------
<?php

while(1)
{
$a[]="aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
echo memory_get_usage() . " BYTES OR " . memory_get_usage()/1024/1024 . " MB\n";
}

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-12 18:26 UTC] rasmus@php.net
-Status: Open +Status: Bogus
 [2011-03-12 18:26 UTC] rasmus@php.net
Set it to 0, not -1 to disable it.
 [2011-03-12 19:26 UTC] carsten_sttgt at gmx dot de
@ Rasmus
> Set it to 0, not -1 to disable it.

In this case you should reclassify this to a documentation problem and not set it to "Bogus" (see QA "Handling bug reports").

From the manual [1]:
| Note that to have no memory limit, set this directive to -1. 


[1] http://de.php.net/manual/en/ini.core.php#ini.memory-limit
 [2011-03-12 19:31 UTC] pajoye@php.net
-Status: Bogus +Status: To be documented
 [2011-03-12 19:31 UTC] pajoye@php.net
> doc
 [2011-03-12 19:42 UTC] rasmus@php.net
Did it work with 0?
 [2011-03-12 19:42 UTC] jsakk at mailmetrash dot com
If I set memory_limit = 0 I get "Could not Start" so I believe -1 is correct as per the php documentation.

That said.

Even if i set it to memory_limit = 5G

I get the same results with it stopping @ approx 1901MB
 [2011-03-12 19:46 UTC] rasmus@php.net
Seems like a Windows-specific issue then. No such problems on Linux/FreeBSD.
 [2011-03-12 19:54 UTC] jsakk at mailmetrash dot com
rasmus thanks for the quick reply.

How can you be sure it's a Windows problem?

If I re-write the same code in C and it has no problem allocating all the RAM.

Perhaps it's a PHP problem on Windows?
 [2011-03-12 19:55 UTC] rasmus@php.net
That's what I meant. And I don't do Windows.
 [2011-03-12 19:58 UTC] jsakk at mailmetrash dot com
thank you rasmus!
Hopefully someone who does Windows will take a look :)
 [2011-03-12 20:22 UTC] pajoye@php.net
I don't think it is a Windows problem but a 32bit vs 64bit one.

Rasmus, I suppose your boxes are 64bit right?
 [2011-03-12 20:23 UTC] rasmus@php.net
Of course.
 [2011-03-12 20:29 UTC] jsakk at mailmetrash dot com
My box is also 64 bit running 64 bit Windows for whatever it's worth.
 [2011-03-12 20:47 UTC] rasmus@php.net
But the app can still only address a 32-bit address space on Windows even if you 
are running 64-bit Windows.
 [2011-03-12 20:58 UTC] jsakk at mailmetrash dot com
My C program is also 32bit and it can allocate the full memory just fine.
 [2011-03-12 21:01 UTC] jsakk at mailmetrash dot com
Also even if that was the case a 32bit program should still be able to access more then 1901MB of RAM.
 [2011-03-12 21:07 UTC] rasmus@php.net
Well, a signed 32-bit integer only gives you 2147483648 so it isn't that far off.
 [2011-03-12 21:27 UTC] jsakk at mailmetrash dot com
holy molly I think you're right but still not 100% sure.
Got to figure out why my C code can allocate more as 32 bit app now.
Just so I understand better there is no 64 bit php version for Windows but there is for *nix?

Thank you rasmus and pajoye!
 [2011-03-12 21:31 UTC] pajoye@php.net
But PHP bins are 32bit. 

It should be possible to alloc more than 2^32 but I'm not sure it is safe to do it 
in PHP, given that many places rely on long instead of size_t to work with 
buffers.
 [2017-01-31 16:38 UTC] mikeotown at msn dot com
Was it ever determined if PHP on 64-bit Windows can only address 2GB of memory?  I'm having a similar issue on a 64-bit machine running Windows 10.
 [2021-07-14 14:35 UTC] cmb@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: cmb
 [2021-07-14 14:35 UTC] cmb@php.net
I'm pretty sure that as of PHP 7.0.0 you can allocate more than 2
GiB on Windows x64 (I'm absultely sure wrt. the actively supported
PHP versions[1]).

On Windows x86, you can allocate up too 2 GiB, and possibly up to
4 GiB (LAA), but not more.

[1] <https://www.php.net/supported-versions.php>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC