由于我将PHP应用程序移动到新服务器(在32位Windows Server 2003 R2上作为Apache 2.2模块运行的PHP / 5.3.8),我在PHP错误日志中出现随机错误:
[09-Jan-2012 19:45:12] PHP Fatal error: Out of memory (allocated 786432) (tried to allocate 17 bytes) in D:\site\util\odbc-connection.php on line 675
[10-Jan-2012 17:56:49] PHP Fatal error: Out of memory (allocated 1310720) (tried to allocate 6144 bytes) in D:\site\logic\data.php on line 630
[10-Jan-2012 17:58:52] PHP Fatal error: Out of memory (allocated 524288) (tried to allocate 393216 bytes) in D:\site\users\edit-user.php on line 458
我因以下原因感到困惑:
是达到memory_limit
时收到的标准错误消息:
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 800001 bytes)
无论如何,memory_limit
默认为服务器上的256MB
,并且在此应用上设置为128MB
(因此524,288字节应该不成问题)。
在报告的行中通常有相当无辜的代码,例如函数定义的开头......
function linea($html){
...或非常小的数组的foreach()循环:
foreach($perfiles_basicos as $c => $v){
我想我已经放弃了所有明显的东西(我甚至在硬盘中的所有* .php,* .ini,.htaccess和* .conf文件中搜索了memory_limit
字符串)我编写了代码来检测并记录对“128MB”限制的更改(没有找到任何内容),所以我现在很无能为力。
任何提示或想法?
更新#1: Apache的error.log
显示我从PHP获得内存不足错误后重新启动了Web服务器。有些是手动重启,有些是崩溃:
zend_mm_heap corrupted
12] [notice] Child 2524: Child process is exiting
[Mon Jan 09 19:45:12 2012] [notice] Parent: child process exited with status 1 -- Restarting.
[Mon Jan 09 19:45:13 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jan 09 19:45:13 2012] [notice] Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 configured -- resuming normal operations
[Mon Jan 09 19:45:13 2012] [notice] Server built: Sep 24 2011 00:32:50
[Mon Jan 09 19:45:13 2012] [notice] Parent: Created child process 6256
[Mon Jan 09 19:45:13 2012] [notice] Disabled use of AcceptEx() WinSock2 API
[Mon Jan 09 19:45:13 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jan 09 19:45:14 2012] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Mon Jan 09 19:45:14 2012] [notice] Child 6256: Child process is running
[Mon Jan 09 19:45:14 2012] [notice] Child 6256: Acquired the start mutex.
[Mon Jan 09 19:45:14 2012] [notice] Child 6256: Starting 400 worker threads.
[Mon Jan 09 19:45:14 2012] [notice] Child 6256: Listening on port 443.
[Mon Jan 09 19:45:14 2012] [notice] Child 6256: Listening on port 80.
更新#2: ...并且ODBC扩展程序正在记录以下错误:
No se puede cargar el controlador especificado debido al error del sistema 8 (Oracle in instantclient_11_2)
...其中system error 8映射到:
ERROR_NOT_ENOUGH_MEMORY 8 (0x8)
没有足够的存储空间来处理此命令。
答案 0 :(得分:9)
我刚刚在PHP树中快速搜索“Out of memory”,发现如果内部分配调用(例如malloc
)失败,则Zend Memory Manager会触发此错误({{3} })。
所以,是的,听起来就像系统内存不足;)