du7999 2018-05-21 09:50 采纳率: 100%
浏览 87

Apache / PHP / Win内存问题,两个不同的系统+代码。 同样的问题

I've been battling this problem for months now. I have two different systems each with different setups and PHP code but both have exactly the same problem.

My server will throw a 500 error and the logs will be filled with memory allocation issues until a restart of Apache.

System ONE

OS: Windows server 2008

XAMPP: PHP 7.1.9 / Apache 2.4.27

Codebase: A small laravel website nothing fancy

System TWO

OS: Windows server 2016

XAMPP: PHP 7.2.3.0 / Apache 2.4.29

Codebase: Some long running php processes, around 2min.

Apache Errors

VirtualFree() failed: [0x000001e7] Attempt to access invalid address. VirtualAlloc() failed: [0x00000008] Not enough storage is available to process this command. VirtualFree() failed: [0x000001e7] Attempt to access invalid address.

PHP Errors

[Mon May 21 09:27:42.078308 2018] [php7:error] [pid 10236:tid 12736] [client 43.245.8.13:1553] PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 6626884 bytes) in C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php on line 141, referer: http://m.facebook.com/

[Mon May 21 09:28:12.703338 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63513] PHP Fatal error: Out of memory (allocated 73400320) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 294

[Mon May 21 09:28:14.640812 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63529] PHP Fatal error: Out of memory (allocated 37748736) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php on line 294

[Mon May 21 09:28:19.218972 2018] [php7:error] [pid 10236:tid 12736] [client 157.49.220.122:64984] PHP Fatal error: Out of memory (allocated 20971520) (tried to allocate 4096 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php on line 161, referer: https://www.facebook.com/

[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 131072 bytes) in C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php on line 141

[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 32768 bytes) in C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php on line 451

[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP Fatal error: Out of memory (allocated 12582912) (tried to allocate 20480 bytes) in Unknown on line 0

What triggers the errors

The errors seem to occur randomly, but not straight away after an Apache restart. As if its hogging memory, however, I have 6GB of 8GB free on the server.

What I've tried so far

Various php.ini memory tweaks, eg memory_limit=1200M and also in script tweaks ini_set('memory_limit', -1);

Apache config tweaks

ThreadStackSize        56*1024*1024
ThreadsPerChild        150
MaxConnectionsPerChild   0
RLimitMEM 99999999999 99999999999999

However, I did notice after the restart it says

AH00118: RLimitMEM not supported on this platform

I've seen these errors scattered around the internet and no one ever seems to find a solution for them. I need PHP on Windows, I'm starting to think I should try IIS.

Are there any other recommendations on Apache config or what else I could try?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?