Fatal error allowed memory size of memcached

fatal error allowed memory size of memcached

The memory usage may also be elsewhere - it could fail here because memory was filled up elsewhere in the script. It looks like your memory. The reason for the error is described as the allowed memory size of 350 was exhausted and an additional 35MB cannot be allocated. So you should increase the. If your server config allows it, and you have enough memory allocated to the server, then you might try increasing the limit to 1024MB - once the installation.

Similar video

How to fix Laravel, php artisan serve - PHP Fatal error: Allowed memory size of ... exhausted.

Fatal error allowed memory size of memcached - there something?

While working on Pressbooks, a multi-site WordPress based web application, I noticed that some of our customers were getting blank pages in the admin section. Specifically, customers with a lot of Sites (or Books as they are known in Pressbooks).

Checking the error logs I saw that these customers were running out of memory.

PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 292913 bytes) in /path/to/object-cache.php on line 212.

First, to temporarilystop the out-of-memory problem so I could profile I added the following to wp-config.php:

define( 'WP_MAX_MEMORY_LIMIT', '512M' );

Next, using Blackfire.IO I was able to determine the following:

Before

That is, when a customer was looking at their dashboard, PHP was consuming 285MB of memory. Most of it the Memcached Object Cache plugin.

That’s weird. I’m using the latest version of the plugin, the plugin is developed by core developers, and no one has reported this before? Or so I thought! Browsing the plugin SVN I see the following change committed to trunk:

Changeset 626248

There’s a few more fixes in there as well. After installing the TRUNK version of this plugin Blackfire.IO displayed:

After

That’s a 273MB improvement!

It took me days to figure out this problem. It would have saved me a lot of time had I seen the new code first.

Bonus info:

  • The code in TRUNK has at least 2 bugs. (…just load the file in PHPStorm and the errors will be underlined in red)
  • Redis Object Cache gives better results.

For now, this is good enough.

I’m running Kopano on a UCS server, release 4.4-4 errata617, all software updated.
kopano-webapp 3.5.14.2539+111.1 all
kopano-webapp-plugin-files 3.0.0.0+118.3 all
kopano-webapp-plugin-filesbackend-owncloud 3.0.0.0+54.3 all
kopano-webapp-plugin-filesbackend-smb 3.0.0.0+36.3 all

Trying to add a webdav share in options->files of the webapp always results in a green light and a tooltip “Account is ready to use”, the quotum info is reported correctly, but every connection is followed by a “Http 500 Internal server error”.

Verifying /var/log/apache2/error.log one can see that

  • kopano doesn’t use memcached (why?) and
  • the script to list all files exhausts the memory limit set in php.ini and throws the 500 error.
    (error.log heavely edited)…
    [:error] [pid 13411] [client 192.168.0.1:50270] [DBG][FilesListModule] [cache] memcached storage could not be loaded. Using files storage., referer: https://myserver.mydomain:30015/webapp/
    [:error] [pid 3767] [client 192.168.0.1:52994] [DBG][FilesListModule] Getting cache for node: fd4aec9e53a237c7a928cf4b562392c1/ ## ludo03db8e887097dd0b96b89e5665bd1d99, referer: https://myserver.mydomain:30015/webapp/
    [:error] [pid 3767] [client 192.168.0.1:52994] [DBG][FilesListModule] Getting cache for node: fd4aec9e53a237c7a928cf4b562392c1/ ## ludo03db8e887097dd0b96b89e5665bd1d99, referer: https://myserver.mydomain.com:30015/webapp/
    [Wed Jun 03 10:04:48.632871 2020] [:error] [pid 3767] [client 192.168.0.1:52994] [DBG][FilesListModule] Getting cache for node: fd4aec9e53a237c7a928cf4b562392c1/ ## ludo03db8e887097dd0b96b89e5665bd1d99, referer: https://thuisip.dyndns-ip.com:30015/webapp/
    etc, etc, etc… until
    PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 135168 bytes) in /usr/share/kopano-webapp/plugins/files/php/modules/class.fileslistmodule.php on line 271, referer: https://myserver.mydomain.com:30015/webapp/
    [Wed Jun 03 10:05:46.350555 2020] [:error] [pid 3758] [client 192.168.0.1:53036] [DBG][AccountStore] Found 1 accounts., referer: https://myserver.mydomain.com:30015/webapp/

Adding a smb share functions correctly.

Can anyone please give me a hint to solve this problem?
Thx.

C) 04:59, 29 May 2009 (UTC)Reply[reply]
Judging by “includes/memcached-client.php” code, MW doesn't support unix sockets for memcached addresses (not in 1.16 yet, at least). And no, leaving the default is unrelated. —HoverHell, 21:10, 23 September 2010 (UTC)

Is this still impossible??? I am using a hosting that does noe allow memcached with ports because of the security problems... this shouldn't be too hard to implement, right?? JEH 2013-08-11

Hi folks!
I've managed to get unix domain socket connections to work with MW Memcached:
$wgMemCachedServers = array("unix:///var/socket/memcached.sock:0");
and then configure your memcached.conf, making sure to deactivate -p and -l options and set -s and -a accordingly. Here's a sample memcached.conf:
# unix domain socket makes it faster, no TCP overhead # be sure to disable -l 127.0.0.1 and -p 11211 -s /var/run/memcached/memcached.sock -a 0766
I submitted a simple patch to get it working - https://gerrit.wikimedia.org/r/#/c/104663/
--Jnatividad (talk) 21:14, 30 December 2013 (UTC)Reply[reply]

How is it possible to clear the cache?[edit]

When I want to change the template of my wiki, many user have because of memcached the old version, although there is a new version online. how can I clear the cache with a ssh command? --tada

Hu... Simply restart the memcached daemons ^^ --77.197.123.56 00:22, 27 June 2009 (UTC)Reply[reply]
Sometimes we can not restart memcached for it is run by root. I use simple mainatenance script such as
<?php $fp = @fsockopen( '127.0.0.1', 11211, $errno, $fsockerr, 1.0 ); fwrite( $fp, "flush_all\r\n" );

--Roma7 13:09, 10 December 2009 (UTC)Reply[reply]

Error with memcached[edit]

I get an error with memcached and mediawiki 1.15.1

Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 122880 bytes) in /var/www/mediawiki-1.15.1/includes/db/LoadBalancer.php on line 315

Can anybody help?

Deciding whether to use memcached[edit]

What is more important in deciding whether to use memcached — size or load? E.g., if I have a wiki that's as large as Wikipedia but doesn't have much load, should I still use memcached? Thanks, Tisane 15:03, 8 May 2010 (UTC)Reply[reply]

Memcached slows server[edit]

Before I had page generation time of about 0.5 seconds, but then I setup a separate server installed with memcached using all default settings. I changed my LocalSettings.php file to use memcached, and now my page load times are about 11.0 seconds. Is this normal for the first couple requests, or what might the problem be? Also, besides changing the settings in LocalSettings.php, and creating the server, is there anything else I need to do? On the page it talks about running "memcached -d -l 127.0.0.1 -p 11211 -m 64". On which server would I run that? --Jer Hughes 05:05, 27 March 2011 (UTC)Reply[reply]

Use memcached only if you have more than one web server. Otherwise, local caching like APC should be used. Max Semenik 07:06, 27 March 2011 (UTC)Reply[reply]
Thanks for the reply. I am using more than one web server. I think I found my problem, but not yet a solution. I think MediaWiki is trying to connect to the memcached server, but is timing-out after about 10-seconds. I do know that my unmodified memcached server is working, as I'm able to successfully run a php test script (outside of MediaWiki but on the same server as it). In my error logs on my MediaWiki server, I'm getting the following errors when MediaWiki is configured to use memcached:
[27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 958 [27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 965 [27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 958 [27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 965 [27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 958 [27-Mar-2011 17:35:43] PHP Warning: Illegal offset type in isset or empty in [...]/w/includes/memcached-client.php on line 965 ...
--Jer Hughes 22:46, 27 March 2011 (UTC)Reply[reply]
Perhaps the server you're trying to connect to isn't actually the one running memcached, or perhaps it's firewalled so that you can't reach it, or maybe you're not connecting to it properly. It's pretty hard to tell, since you haven't told us anything about your configuration. —Emufarmers(T

Finding/Resolving Memory Related PHP errors in Acquia Cloud

Issue

How can I fix PHP errors on my website?

Resolution

When it comes to performance tuning your Drupal application on Acquia Cloud and in other hosting environments; or, just figuring out why your site may be running slower than expected, there is a wealth of information that can be gleaned from your PHP errors log (php-errors.log), Drupal Watchdog log (drupal-watchdog.log) and FPM errors log (fpm-error.log). 

PHP Memory Limit errors 

The PHP memory limit is the maximum amount of RAM memory, in M, that a single PHP process can consume. Memory used by the MySQL client counts against the PHP memory limit. The default setting for PHP memory is adequate for most Drupal applications on Acquia Cloud, but you may see the following errors which are clear signs that the memory limit may be set too low. 

  • WSOD (White Screen of Death) errors, these are characterized by going to the page, and seeing a blank page (a blank white screen) with no error message. 
  • Temporary Unavailable errors - on a page, or on a site action, for example, uploading large files, or running long reports.
  • Check the php-errors.log for errors similar to this one: 

The best way to resolve these ssiues is within the application. Use How investigate Memory Consumption problems to help you identify resource intensive areas of your application. We recommend making changes in your code to reduce the memory use; however, it can help to increase the PHP memory limit in some cases. This can be changed either through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in Configuring PHP Settings) or through a support ticket for Site Factory products. 

PHP Max Execution Time

PHP Max Execution is the amount of time a single PHP process can run (in seconds). We recommend that you resolve this problem by identifying slow processes and refactoring the code that makes the request or set_time_limit() function.

Search the the fpm-error.log for max_children errors - which can indicate that the available PHP/FPM processes are consumed. This can also be indicated by Temporarily Unavailable, or White Screen of Death errors. 

Our Acquia Cloud Professional and Acquia Cloud Enterprise products can adjust PHP Max Execution time through the Acquia Cloud web site (Configuring max execution time).

PHP OPcache

OPcache is the cache for the pre-compiled bytecode. It is faster than using PHP to load and parse the PHP scripts that make up your Drupal application for each and every HTTP (HTTPS) request. The OPcache in PHP 7 should be set to be large enough to store compiled code for your applications' PHP scripts, but we recommend that you also set this value to be low enough to avoid allocating too much RAM to an underused cache. This is called APC in PHP 5.5 and below.

  • Check the php-errors.log for errors similar to this one:  

This value can be changed under APC memory settings (this is called APC in PHP 5.5 and earlier) through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in Configuring PHP Settings) or through a support ticket for our Site Factory customers. 

There is a tool available that will help you analyze what is in OPCache for your application: https://github.com/rlerdorf/opcache-status.

OPcache Interned Strings buffer 

The Interned Strings buffer is the amount of memory (in M) used to store identical strings (detected by PHP). By default, this is a shared buffer allowing all Drupal PHP processes to reference it across multiple PHP/FPM processes - saving memory.

Drupal 8 applications, in general, make greater use of the interned strings buffer, we recommend that you check the fpm-error.log for the following type of error

This value can be changed under OPcache interned strings buffer through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in OPcache interned strings buffer) or through a support ticket for our Site Factory customers.

APCu or APC user_cache errors

APC User cache is PHP the part of APC that is not a part of OPcache. It was rarely used in Drupal 7  (for example, the default Acquia Value apc.shm_size= 8M is okay for most sites).  

In general, Drupal 8 sites make much greater use of the APC user cache. For a single web site, we recommend increasing the PHP user cache apc.shm_size=16M or the default PHP value of 32M. If you are using our Site Factory applications, or a larger multi-site, you may need to increase the APC user_cache setting even further.   

A clear sign that the APC User cache is set too small is this type of error in your php-errors.log: 

Having your application try to allocate too much information in a small cache can result in slow site performance, and 'hung' PHP/FPM processes that cause your site to fail. 

This value can be changed under APCu size through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in APCu size) or through a support ticket for our Site Factory customers. 

See this article How to monitor and tune APCu for additional tips and tools to improve the performance of your application.

See the following references for information about how to find, and search through your log files: 

C)
04:21, 28 March 2011 (UTC)Reply[reply]
I'm pretty sure its not a firewall or memcached server issue, because I can connect to that server, and see things caching, when running simple memcached test scripts on the server MediaWiki is running on. I'm thinking that it is a connection issue, but I just don't know where. I did some profiling and came back with these results:
10.542311 1 - MediaWiki::performAction 10.542140 1 - Article::view 10.170179 193 - wfMsgReal 10.004816 1 - MessageCache::load 0.641324 1 - WebStart.php-conf 0.316287 1 - Parser::parse 0.316239 1 - Parser::parse-unknown 0.305995 1 - MediaWiki::finalCleanup ...
Further, the only settings I have for memcached on the wiki server is:
$wgMainCacheType = CACHE_MEMCACHED; $wgMemCachedServers = array("XX.XX.XXX.XXX:XXXXX"); // Using my real IP address and port
--Jer Hughes 01:25, 26 April 2011 (UTC)Reply[reply]

Move of wiki/memcached to Manual:Memcached[edit]

This should be moved to the Manual namespace...
-- Timmay911 (talk) 21:16, 15 January 2017 (UTC)Reply[reply]

Use of Memcached for sessions not recommended by Memcached[edit]

Is it worth noting somewhere that Memcached docs recommend%20not%20using%20Memcached%20for%20sessions? and potentially recommending that anyone wanting to follow that advise use `CACHE_DB` instead?

Redis is a good alternative, since it allows to store data on disk, preventing (most) data loss on server restart. --Ciencia Al Poder (talk) 08:52, 16 August 2021 (UTC)Reply[reply]