Upper memory limit for PHP/Apache

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 08:52:39

You're running on a 64-bit operating system, but Apache and PHP are likely still 32-bit. If you're using mod_php, apache would be the limiting factor here.

32-bit processes are limited about 2GiB of RAM unless you used the /3GB switch and the software is aware of 3GB support.

That still leaves up about 200 MiB that seems unused, but its small enough that it can be used by various libraries that all have to be loaded in memory

As far as I know, the library usage won't show up in the committed memory, but still counts towards the 2GiB limit (much like device memory counts towards the 4GiB limit on 32-bit windows. Where installing 2 GiB graphics card brings you down to under 2GiB of usable RAM).

Most likely solution? Install a 64-bit PHP, and then dispatch it to that (using a system() call, perhaps)

Using Acquia Dev Desktop, I had many memory limit crashes.

After having increased the memory limit into PHP.ini.

php_value memory_limit                  1024M
php_value max_execution_time            3000

This issue was less frequent but still occuring ( Especially with Feature Recreate )

Into my httpd.conf I increased the StackThread to 16M

ThreadStackSize 16*1024*1024

And it solved the memory crash issue. Hope it can help

Which PHP version are you using?

The memory_limit variable is, or was, contained in a 32-bit integer, so can not go above 2GB.

See: http://bugs.php.net/bug.php?id=39132&edit=1

From the bottom comment on that bug report, it might be the routine that translates the human readable form to a number, try putting it in digits.

Check your Apache config (e.g., httpd.conf). There's likely an RLimitMEM directive limiting the memory allow for children processes handling requests.

So, you can set your PHP limit all you want, if Apache spawns the process with a memory limit, you can't exceed that.

If you're on a hosted service and have a shared server, likely you don't have access to this config and need to work with your provider. As you can see, it's configuration that applies server-wide... you're not likely going to get them to change this. Then again, if you're looking to spawn bigger than 1.5Gig processes, you prolly should be either solving the problem a different way (others have suggested this) or getting a dedicated server of some kind (e.g. EC2).

For example:

/usr/local/apache/conf
#RLimitMEM 85643200 104857600   # Limit to: 80Mb / process, 100Mb total
RLimitMEM 134217728 537395200   # Limit to: 128Mb / Process, 512Mb total

The issue is likely to be caused by running 32-bit apache and php. Try upgrading these to 64-bit binaries and see if that fixes the issue.

Try this

set_time_limit(300);
ini_set('memory_limit', '20000M');
Pradeep Singh

Try this:

#php_value memory_limit 300M 
#php_value upload_max_filesize 200M 
#php_value post_max_size 200M 
#php_value max_execution_time 80000 
#php_value max_input_time 80000   

try ini_set('memory_limit', '-1');

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!