首页 > 解决方案 > Apache/PHP/Win 内存问题,两种不同的系统+代码。同样的问题

问题描述

几个月来我一直在与这个问题作斗争。我有两个不同的系统,每个系统都有不同的设置和 PHP 代码,但都有完全相同的问题。

我的服务器将抛出 500 错误,并且日志将充满内存分配问题,直到重新启动 Apache。

系统一

操作系统:Windows 服务器 2008

XAMPP:PHP 7.1.9 / Apache 2.4.27

代码库:一个没有什么花哨的小型 laravel 网站

系统二

操作系统:Windows 服务器 2016

XAMPP:PHP 7.2.3.0 / Apache 2.4.29

代码库:一些长时间运行的 php 进程,大约 2 分钟。

阿帕奇错误

VirtualFree() 失败:[0x000001e7] 尝试访问无效地址。VirtualAlloc() 失败:[0x00000008] 没有足够的存储空间来处理此命令。VirtualFree() 失败:[0x000001e7] 尝试访问无效地址。

PHP 错误

[Mon May 21 09:27:42.078308 2018] [php7:error] [pid 10236:tid 12736] [client 43.245.8.13:1553] PHP 致命错误:内存不足(分配 2097152)(试图分配 6626884 字节) C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php 在第 141 行,引用者: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 致命错误:内存不足(分配 73400320)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php 在第 294 行

[Mon May 21 09:28:14.640812 2018] [php7:error] [pid 10236:tid 12736] [client 122.170.190.70:63529] PHP 致命错误:内存不足(分配 37748736)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php 在第 294 行

[Mon May 21 09:28:19.218972 2018] [php7:error] [pid 10236:tid 12736] [client 157.49.220.122:64984] PHP 致命错误:内存不足(分配 20971520)(试图分配 4096 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Concerns\HasEvents.php 在第 161 行,引用者: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 致命错误:内存不足(分配 12582912)(试图分配 131072 字节) C:\xampp\htdocs\*\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php 在第 141 行

[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP 致命错误:内存不足(分配 12582912)(试图分配 32768 字节) C:\xampp\htdocs\*\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php 在第 451 行

[Mon May 21 09:28:27.125182 2018] [php7:error] [pid 10236:tid 12704] [client 150.143.104.159:12178] PHP 致命错误:内存不足(分配 12582912)(试图分配 20480 字节)第 0 行未知

什么触发了错误

这些错误似乎是随机发生的,但不是在 Apache 重新启动后立即发生。然而,就好像它占用了内存一样,我在服务器上有 6GB 的 8GB 空闲空间。

到目前为止我尝试过的

各种 php.ini 内存调整,例如memory_limit=1200M脚本调整 ini_set('memory_limit', -1);

Apache 配置调整

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

但是,我确实在重启后注意到它说

AH00118: RLimitMEM not supported on this platform

我已经看到这些错误散布在互联网上,似乎没有人找到解决方案。我需要 Windows 上的 PHP,我开始认为我应该尝试 IIS。

关于 Apache 配置还有什么其他建议或者我可以尝试什么?

标签: phplaravelapache

解决方案


推荐阅读