Apache crash : Cannot allocate memory - php

I am experiencing a recurring issue why my ubuntu server complete becomes unavailable around the same time for the past two days. I cant even SSH into it during the crash.
The Ubuntu server is on a amazon aws t2.micro instance, running on 1 gb of ram , Ubuntu 16.04
The apache error logs are shown below
[Wed Aug 30 18:02:23.710072 2017] [autoindex:error] [pid 7505] [client 60.191.38.77:57957] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.cgi,$
[Wed Aug 30 18:02:23.710126 2017] [:error] [pid 7505] [client 60.xx.xx.xx:57957] script '/var/www/html/404.php' not found or unable to stat
[Wed Aug 30 19:11:54.375001 2017] [autoindex:error] [pid 11307] [client 45.55.21.189:52050] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.html,index.cgi$
[Wed Aug 30 19:11:54.376134 2017] [:error] [pid 11307] [client 45.xx.xx.xx:52050] script '/var/www/html/404.php' not found or unable to stat
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
mmap() failed: [12] Cannot allocate memory
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[Wed Aug 30 20:50:00.570286 2017] [core:notice] [pid 31139] AH00051: child pid 17670 exit signal Aborted (6), possible coredump in /etc/apache2
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[Wed Aug 30 21:03:27.234926 2017] [core:notice] [pid 31139] AH00051: child pid 18507 exit signal Aborted (6), possible coredump in /etc/apache2
[Wed Aug 30 21:03:27.354905 2017] [core:notice] [pid 31139] AH00051: child pid 18511 exit signal Aborted (6), possible coredump in /etc/apache2
[Wed Aug 30 21:03:27.354927 2017] [core:notice] [pid 31139] AH00051: child pid 18512 exit signal Aborted (6), possible coredump in /etc/apache2
[Wed Aug 30 21:03:42.865027 2017] [core:notice] [pid 31139] AH00051: child pid 18506 exit signal Aborted (6), possible coredump in /etc/apache2
[Wed Aug 30 21:03:46.984235 2017] [core:notice] [pid 31139] AH00051: child pid 18529 exit signal Aborted (6), possible coredump in /etc/apache2
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[crit] Memory allocation failed, aborting process.
[Wed Aug 30 21:14:50.194072 2017] [core:notice] [pid 31139] AH00051: child pid 18605 exit signal Segmentation fault (11), possible coredump in /etc/apache2
[Wed Aug 30 21:14:50.482541 2017] [core:notice] [pid 31139] AH00051: child pid 18618 exit signal Aborted (6), possible coredump in /etc/apache2
[Thu Aug 31 07:09:50.271441 2017] [mpm_prefork:notice] [pid 1321] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Thu Aug 31 07:09:50.274044 2017] [core:notice] [pid 1321] AH00094: Command line: '/usr/sbin/apache2'
The server becomes inaccessible around this time
Wed Aug 30 19:11:54 based on the logs and traffic monitor on AWS.
I have little understanding of how Apache works in terms of memory and concurrent connections. The website I have in it has low traffic. Is there some config file I might have messed up? .BTW memory_limit is -1 no limit as per the PHP docs
Or what can I do to find the cause of the problem, I am thinking of migrating the server files to a AWS beanstalk instance (A deploying aide plus scaling aide,AFAIK) a fresh start.
Is there away I could know the script(s) that might have caused the crash.I have too many scripts plus running on laravel PHP framework + third party scripts would really make it hard to outline which one is the suspect.
I would greatly appreciate an answer that explains the error log.i.e
A script did this...
Apache seems to have done this...
Ubuntu then did this...
Which led to this...

Borrowing from what #arkascha said in the comments the crash was caused by some script that was using a lot of memory and not well optimised.
The following steps will help others facing similar problems.
Limit the php script memory limit to something reasonable according
to what you running.
Have Swap files, really important I didn't have one which caused the
whole system to crash during memory intensive processing. (In my
case Apache was using all of the available memory from my 1GB,
literally causing the system to crash)
(A swap file is basically a file on a hard disk used to provide space for programs that have been transferred from the processor's memory. An extra RAM,but slow)
Find the root of the problem (I haven't found a technique or tool
outline php memory usage but i think there some available). Another
way is too look for scripts with long queries (multiple joins,etc) these are typically the cause.
Probably obvious but maybe not so obvious, get some additional RAM
for your server. You webapp may require more than you currently
have.
Caching data. There are many techniques in doing this. Basically it
involves loading static data where dynamic loading is not really needed.

Related

Apache Error AH02538: Child: Parent process exited abruptly. Child process is ending xampp PHP 7

I have a software project with PHP 7 on XAMPP version 3.2.2
The problem is that the Apache keeps stopping constantly
I tried put this on the httpd.conf file but the problem persist
<IfModule mpm_winnt_module>
ThreadStackSize 8388608
</IfModule>
The error log shows this:
[Fri Jun 07 15:57:50.687867 2019] [php7:error] [pid 4924:tid 1620] [client 172.16.5.211:57554] PHP Fatal error: Out of memory (allocated 4194304) (tried to allocate 4096 bytes) in C:\\xampp\\apps\\moodle\\htdocs\\lib\\navigationlib.php on line 3297
[Fri Jun 07 15:57:55.140977 2019] [mpm_winnt:crit] [pid 4924:tid 472] AH02538: Child: Parent process exited abruptly. Child process is ending
[Fri Jun 07 15:57:58.922259 2019] [core:warn] [pid 872:tid 436] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Fri Jun 07 15:57:59.000372 2019] [mpm_winnt:notice] [pid 872:tid 436] AH00455: Apache/2.4.29 (Win32) OpenSSL/1.1.0g PHP/7.2.1 configured -- resuming normal operations
[Fri Jun 07 15:57:59.000372 2019] [mpm_winnt:notice] [pid 872:tid 436] AH00456: Apache Lounge VC15 Server built: Nov 3 2017 10:30:36
[Fri Jun 07 15:57:59.000372 2019] [core:notice] [pid 872:tid 436] AH00094: Command line: 'c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache'
[Fri Jun 07 15:57:59.000372 2019] [mpm_winnt:notice] [pid 872:tid 436] AH00418: Parent: Created child process 1872
[Fri Jun 07 15:57:59.719114 2019] [mpm_winnt:notice] [pid 1872:tid 460] AH00354: Child: Starting 150 worker threads.
I appreciate your help
You can run this: memory_get_usage that returns the amount of memory allocated to PHP. (https://www.php.net/manual/en/function.memory-get-usage.php)
And this: memory_get_peak_usage that returns the peak of memory allocated by PHP. (https://www.php.net/manual/en/function.memory-get-peak-usage.php)
Then tweak ini_set('memory_limit', '16M'); (16 M in the example, just set properly depending on what you get with the previous commands).
Here is the documentation for ini_set: https://www.php.net/manual/en/function.ini-set.php
You may find interesting hints here too:
Fatal error: Out of memory, but I do have plenty of memory (PHP)
If you want to edit php.ini: memory_limit is for configuring the maximum amount of memory in bytes that a script is allowed to allocate. (https://www.php.net/manual/en/ini.core.php#ini.memory-limit)

Cannot allocate memory: fork: Unable to fork new process on aws

I have been getting this error in my server log file.
[Sun Jan 29 00:22:43.570300 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:22:53.742820 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:03.771702 2017] [core:notice] [pid 1205] AH00051: child
pid 22134 exit signal Aborted (6), possible coredump in /etc/apache2
[Sun Jan 29 00:23:03.876081 2017] [core:notice] [pid 1205] AH00051: child
pid 22135 exit signal Aborted (6), possible coredump in /etc/apache2
[Sun Jan 29 00:23:04.899489 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:14.931272 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:24.965639 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
[Sun Jan 29 00:23:35.031174 2017] [mpm_prefork:error] [pid 1205] (12)Cannot
allocate memory: AH00159: fork: Unable to fork new process
help to solving out the issue.
The cannot allocate memory error usually points to an Out Of Memory (OOM) error.
This can happen very often on the smaller EC2 Instances, e.g. if you haven't tuned the maximum memory your apps can request from the operating system.
Your app (in this case Apache) attempts to allocate some memory (which it expects it should be able to request, based on its config) and the OS simply doesn't have enough to give it.
Some common solutions:
More Memory
Upgrade to a larger EC2 instance, with, well, simply more memory available. This clearly does not solve the problem's root cause, but - given low enough traffic - it could even cause it to stop appearing altogether.
This is only an option if your budget allows it, of course...
Add Hard-Disk-Backed Memory (Swap)
To be more precise: Consider adding swpa
As to how, the below creates a 4GB swapfile:
sudo dd if=/dev/zero of=/var/swapfile bs=1M count=4096
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
Word of warning: swap, when used inappropriately, can easily lead into nasty situations, such as thrashing
Use Existing Memory Wisely
You'll want to read up on Apache Performance Tuning
Hope this helps!
I was facing the same issue on a Wordpress application (PHP v7.4) being served from a Docker container running on an ECS cluster. Following steps helped me resolve the issue:
Increase the Task Memory (MiB) and Task CPU (unit) in the task definition based on your application memory requirements.
Also increase the Hard/Soft memory limits (MiB) in the Container definition if defined earlier.
Update the ECS cluster to point to the new task definition.
Kill the running tasks to force ECS service to start a fresh task as per the new task definition.

APC and child pid XXXXX exit signal Segmentation fault [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
First I had xCache installed on server, I had xCache on lot of my servers but in this one after couple of days you go nothing except a blank page with this error in apache error log:
child pid XXXXX exit signal Segmentation fault
As far as I know this mean some sort of memory corruption.
So I removed xCache from php.ini and installed APC. But things are worse now. After one hour or less/more server become unresponsive. I can clearly see in my website's server-status that there are lot of connections in W mode. And they dont have any thing in common. Some of them are from Joomla (first page) and some from vBulletin (forums) and some other are about other custom codes.
If I let it for more time I will going to have this error in Apache error log:
Server reached MaxClients setting, consider raising the MaxClients setting
Apache is in mod_php and mod_ruid2 mode.
Here is result of server-status when hanged:
Server uptime: 52 minutes 57 seconds
Total accesses: 31025 - Total Traffic: 279.0 MB
CPU Usage: u418.14 s64.28 cu0 cs0 - 15.2% CPU load
9.77 requests/sec - 89.9 kB/second - 9.2 kB/request
398 requests currently being processed, 27 idle workers
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WWWWWWWWWWWWWWWWWWWWWWWWW.......................................
WW___WW_WW_W_WWW__WWWW_W_.......................................
_W___W___WW_W_W_W_W______.......................................
Here is error log for xCache (lot of these lines):
[Thu Mar 28 09:50:38 2013] [notice] child pid 1607 exit signal Aborted (6)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 09:51:57 2013] [notice] child pid 1643 exit signal Aborted (6)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 09:52:32 2013] [notice] child pid 1724 exit signal Aborted (6)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 09:55:21 2013] [notice] child pid 1672 exit signal Aborted (6)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 09:55:56 2013] [notice] child pid 1471 exit signal Aborted (6)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 09:56:49 2013] [notice] child pid 1753 exit signal Aborted (6)
[Thu Mar 28 09:58:29 2013] [notice] child pid 1810 exit signal Segmentation fault (11)
[Thu Mar 28 09:58:29 2013] [notice] child pid 1877 exit signal Segmentation fault (11)
httpd: /usr/src/xcache-2.0.0/utils.c:589: xc_sandbox_error_cb: Assertion `sandbox != ((void *)0)' failed.
[Thu Mar 28 10:01:34 2013] [notice] child pid 1844 exit signal Segmentation fault (11)
[Thu Mar 28 10:01:34 2013] [notice] child pid 1913 exit signal Aborted (6)
[Thu Mar 28 10:01:34 2013] [notice] child pid 1941 exit signal Segmentation fault (11)
[Thu Mar 28 10:01:36 2013] [notice] child pid 2007 exit signal Segmentation fault (11)
[Thu Mar 28 10:01:37 2013] [notice] child pid 2035 exit signal Segmentation fault (11)
[Thu Mar 28 10:01:37 2013] [notice] child pid 2036 exit signal Segmentation fault (11)
Error log for APC before reaching max client (from one restart to other restart):
[Thu Mar 28 19:17:10 2013] [notice] Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.0-fips DAV/2 PHP/5.2.17 configured -- resuming normal operations
[Thu Mar 28 19:21:40 2013] [notice] child pid 1356 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:41 2013] [notice] child pid 1520 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:42 2013] [notice] child pid 1330 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:42 2013] [notice] child pid 1518 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:46 2013] [notice] child pid 1967 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:46 2013] [notice] child pid 1968 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:49 2013] [notice] child pid 1939 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:50 2013] [notice] child pid 2034 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:51 2013] [notice] child pid 2062 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:57 2013] [notice] child pid 2091 exit signal Segmentation fault (11)
[Thu Mar 28 19:22:58 2013] [notice] child pid 2090 exit signal Segmentation fault (11)
[Thu Mar 28 19:25:34 2013] [notice] caught SIGTERM, shutting down
[Thu Mar 28 19:25:37 2013] [notice] SSL FIPS mode disabled
[Thu Mar 28 19:25:37 2013] [warn] RSA server certificate CommonName (CN) `localhost' does NOT match server name!?
[Thu Mar 28 19:25:37 2013] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Mar 28 19:25:37 2013] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Mar 28 19:25:38 2013] [notice] SSL FIPS mode disabled
[Thu Mar 28 19:25:38 2013] [warn] RSA server certificate CommonName (CN) `localhost' does NOT match server name!?
[Thu Mar 28 19:25:38 2013] [warn] Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Thu Mar 28 19:25:38 2013] [notice] Apache/2.2.24 (Unix) mod_ssl/2.2.24 OpenSSL/1.0.0-fips DAV/2 PHP/5.2.17 configured -- resuming normal operations
Little from PHP Info:
System Linux xxx.xxxxx.com 2.6.32-358.0.1.el6.x86_64 #1 SMP Wed Feb 27 06:06:45 UTC 2013 x86_64
Build Date Mar 17 2013 12:55:14
Configure Command './configure' '--with-apxs2' '--with-curl=/usr/local/lib' '--with-gd' '--with-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-pdo-mysql=/usr' '--with-pcre-regex=/usr/local' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-xsl' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-exif' '--enable-ftp' '--enable-gd-native-ttf' '--enable-magic-quotes' '--enable-safe-mode' '--enable-soap' '--enable-sockets' '--enable-mbstring' '--enable-zip' '--enable-wddx'
Server API Apache 2.0 Handler
Virtual Directory Support enabled
Configuration File (php.ini) Path /usr/local/lib
Loaded Configuration File /usr/local/lib/php.ini
Scan this dir for additional .ini files (none)
additional .ini files parsed (none)
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams https, ftps, compress.zlib, php, file, data, http, ftp, zip
Registered Stream Socket Transports tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed
APC settings:
enabled
Version 3.1.13
APC Debugging Disabled
MMAP Support Enabled
MMAP File Mask no value
Locking type pthread read/write Locks
Serialization Support php
Revision $Revision: 327136 $
Build Date Mar 28 2013 12:40:18
Php -v:
PHP 5.2.17 (cli) (built: Mar 17 2013 12:55:24)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
httpd -V:
Server version: Apache/2.2.24 (Unix)
Server built: Mar 10 2013 09:18:00
Server's Module Magic Number: 20051115:31
Server loaded: APR 1.4.6, APR-Util 1.4.1
Compiled using: APR 1.4.6, APR-Util 1.4.1
Architecture: 64-bit
Server MPM: Worker
threaded: yes (fixed thread count)
forked: yes (variable process count)
Server compiled with....
-D APACHE_MPM_DIR="server/mpm/worker"
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=128
-D HTTPD_ROOT="/etc/httpd"
-D SUEXEC_BIN="/usr/sbin/suexec"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="conf/mime.types"
-D SERVER_CONFIG_FILE="conf/httpd.conf"
Any Idea?! I will reward 50 :)
From the looks of your server status page, you are trying to run PHP as mod_php with a threaded Apache MPM. Many PHP extensions, likely including APC and Xcache, are not thread-safe. As such, they will crash frequently under load.
You will need to switch Apache to the prefork MPM, or run PHP as CGI or FastCGI.

Why would a PHP app be generating intermittent segfaults?

I'm doing some load testing on a PHP app (it's a symfony app, if that matters), and the logs are full of errors like these. I'm struggling to work out why these segfaults are occurring.
[Wed Mar 13 00:54:47 2013] [notice] child pid 18830 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump
[Wed Mar 13 00:54:55 2013] [notice] child pid 19016 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump
[Wed Mar 13 00:54:56 2013] [notice] child pid 19002 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump
[Wed Mar 13 00:54:58 2013] [notice] child pid 19041 exit signal Bus error (7), possible coredump in /tmp/apache2-gdb-dump
When I generate a backtrace from the core dumps I get
[New LWP 588] [Thread debugging using libthread_db enabled] Using host
libthread_db library
"/lib/i386-linux-gnu/tls/i686/nosegneg/libthread_db.so.1". Core was
generated by `/usr/sbin/apache2 -k start'. Program terminated with
signal 7, Bus error.
0 lex_scan (zendlval=0xb6d2ce38) at /build/buildd/php5-5.4.6/Zend/zend_language_scanner.c:2260
Thread 1 (Thread 0xb7485700 (LWP 588)):
0 lex_scan (zendlval=0xb6d2ce38) at /build/buildd/php5-5.4.6/Zend/zend_language_scanner.c:2260
So perhaps it's something to do with parsing? I know little about php internals however, so am uncertain. What might be causing this?

Random "PHP Fatal error: Out of memory" errors

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 ;)

Categories