3

I am locally hosting PHP scripts in PhpStorm using the "PHP Built-in Web Server" configuration. One script needs much memory, so I added ini_set('memory_limit', 8589934592); # 8GiB at the beginning of it (Setting it works, I checked it with ini_get('memory_limit')).

But when I request the referring url, the execution of the script fails with the following error message in the error log:

PHP Fatal error: Out of memory (allocated 1793064960) (tried to allocate 8334 bytes) in ...

It is only able to allocate about 1.7GiB.

Does anybody know, why this happens? I assume that the PHP Built-in Webserver has a memory limit, but I cannot find anything about that.


PS: I'm using PHP v5.6, Windows 8 and PhpStorm 10.0.3


Edit: My PC has about 10Gib free RAM to use

Leifb
  • 370
  • 7
  • 20
  • 1
    Very interesting question - I'm curious to see a proven answer. From what you've observed (and tested), I'd guess the answer is a resounding "Yes, and it isn't well documented"... – wally Mar 16 '16 at 10:19
  • I think a better alternative is to configure at the `php.ini` level and for your case you should be looking for `php.ini for your cli`. On my ubuntu is located at `/etc/php5/cli/php.ini`, you'll have to look for mac. – Aukhan Mar 16 '16 at 10:44
  • Besides my problem seems to be solved by now, I don't want to change the `'memory_limit'` in the `php.ini`, because the default should not allow such a high memory usage. It is an exception for this single script. – Leifb Mar 16 '16 at 14:02

1 Answers1

3

Do you run the webserver in 32 bit? If so, it might only be allowed to use max. 2 GB: How much memory can a 32 bit process access on a 64 bit operating system?

I think you can check this with the PHP_INT_SIZE constant: Checking if your code is running on 64-bit PHP

Community
  • 1
  • 1
Veda
  • 2,025
  • 1
  • 18
  • 34