2012-01-10 59 views
9

由於我將PHP應用程序移動到新服務器(在32位Windows Server 2003 R2上作爲Apache 2.2模塊運行的PHP/5.3.8),我收到了隨機錯誤在PHP錯誤日誌:隨機「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 

我很困惑,原因如下:

  1. 這是當達到memory_limit你得到標準的錯誤消息:

    Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 800001 bytes) 
    
  2. 無論如何,memory_limit默認爲256MB在服務器上,並在此應用程序上設置爲128MB(因此524,288字節應該不成問題)。

  3. 在報告行有常很無辜的代碼,如函數定義開始......

    function linea($html){ 
    

    ...或的foreach()循環非常小的數組:

    foreach($perfiles_basicos as $c => $v){ 
    

我想我已經丟棄了所有明顯的東西(我甚至在硬盤中搜索了所有* .php,* .ini,.htaccess和* .conf文件中的memory_limit字符串)和I 'w w ritten代碼來檢測和記錄「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) Not enough storage is available to process this command.

+0

你使用任何框架? – Gerep 2012-01-10 18:07:19

+3

您是否檢查了系統上的內存使用情況? OOM通常在系統無法物理分配內存時發生,而不是在PHP達到了對請求的限制時。 – 2012-01-10 18:08:37

+0

沒有框架,只是香草PHP。我會嘗試監視系統的內存。 – 2012-01-11 08:18:36

回答

8

我只是在PHP樹中快速搜索「內存不足」,發現這個錯誤是由Zend內存管理器如果內部分配呼叫(例如, malloc)失敗(see code)。

所以,是的,聽起來像系統內存不足;)

+0

是的,這是我甚至沒有考慮過的簡單而明智的解釋。目前,服務器幾乎處於空閒狀態,任務管理器顯示具有極高虛擬內存使用率的「wmicpa.exe」進程。我最好問問系統管理員。 – 2012-01-11 08:17:44

+0

我仍然不知道錯誤的確切原因,但是您的答案和Apache錯誤日誌中的「zend_mm_heap已損壞」消息指出了某些內存分配問題,這些問題超出了我的範圍。 – 2012-01-20 09:10:49