Since I moved a PHP app to a new server (PHP/5.3.8 running as Apache 2.2 module on 32-bit Windows Server 2003 R2) I'm getting random errors in the PHP error log:
[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
I'm confused for the following reasons:
It is not the standard error message you get when memory_limit
is reached:
Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 800001 bytes)
Whatever, memory_limit
defaults to 256MB
on the server and is set to 128MB
on this app (thus 524,288 bytes should not be a problem).
In the reported lines there's normally pretty innocent code, such as the start of function definitions...
function linea($html){
... or foreach() loops of very small arrays:
foreach($perfiles_basicos as $c => $v){
I think I've already discarded all the obvious stuff (I've even searched for the memory_limit
string in all *.php, *.ini, .htaccess and *.conf files in the hard disk) and I've written code to detect and log changes to the "128MB" limit (nothing was ever found) so I'm pretty clueless right now.
Any hint or idea?
Update #1: Apache's error.log
shows that the web server gets restarted after I get an Out of memory error from PHP. Some are manual restarts and some are crashes like this:
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.
Update #2: ... and the ODBC extension is logging the following error:
No se puede cargar el controlador especificado debido al error del sistema 8 (Oracle in instantclient_11_2)
... where system error 8 maps to:
ERROR_NOT_ENOUGH_MEMORY 8 (0x8)
Not enough storage is available to process this command.
I just did a quick search for "Out of memory" in the PHP tree and found that this error is triggered by the Zend Memory Manager if an internal allocation call (e.g. malloc
) fails (see code).
So, yeah, sounds like the system went out of memory ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With