0

I'm stuck trying to figure out what seems to be a very common problem, the above mentioned "Allowed memory size of (...) exhausted". After developing my first theme I was moving it (just the theme, not the whole WP installation) from my development computer to my production server. After installing WP everything seemed fine and the site was working great with the default theme. Upon activating my custom theme however WP started throwing the error,

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 523800 bytes) in /srv/www/my.domain.com/public_html/wp-includes/cache.php on line 113

Worth mentioning is that I've never had any issues like this during development.

I've tried to increase both the memory limit in php.ini as well as setting the WP_MEMORY_LIMIT constant in wp-config without luck.

php -i | grep memory
memory_limit => 128M => 128M

cat wp-config.php | grep MEMORY
define('WP_MEMORY_LIMIT', '128M');

As you can see I've worked my way up to 128M. Still hitting the error I'm thinking this is getting ridiculous and not likely the source of my problem. As far as I can recall I never had to go much beyond 32M on much larger WP installations in the past.

9
  • Works the settings of Memory Limit? Also a chance to set via ini_set( 'memory_limit', WP_MEMORY_LIMIT ); after your settings in the wp-config.php.
    – bueltge
    Jan 21, 2014 at 8:05
  • have you tried to turn off plugins? Jan 21, 2014 at 8:13
  • @bueltge Sure, I'll try that.
    – Index
    Jan 21, 2014 at 8:16
  • @MarkKaplun Yes, in the sense that the site doesn't have any.
    – Index
    Jan 21, 2014 at 8:17
  • 1
    Without seeing code it's hard to say, but you want to look for any loops for foreach while which are allocating memory. Chances are you have an infinite loop somewhere in your code.
    – Twifty
    Jan 21, 2014 at 10:11

2 Answers 2

0

Turns out this issue was caused by bad code (a missing assert) in my theme. More specifically the theme requires a custom navigation menu. As this menu hadn't been created and assigned the site crashed. Why this caused an memory exhaustion error on my production server and not my development computer I unfortunately don't know.

-1

Sometime ini_set('memory_limit', '128M');

gives error if you don't have permission to change.

This will work fine if you have permission to change the limits.

This you find in mysql if you are using mysql database

Path for finding the answer is

mysql\bin\my.ini

ini_set('memory_limit, -1'); overrides the default PHP memory limit.

Another answer will be by modifying .htaccess file Open or create the .htaccess file in the root folder and add the following code: 1 php_value upload_max_filesize 64M 2 php_value post_max_size 64M

Again, it is important that we emphasize that if you are on a shared hosting package, then these techniques may not work. In that case, you would have to contact your web hosting provider to increase the limit for you.

2
  • 1
    Please explain why you are suggesting this code for a site. What are the consequences that can happen if the code is implemented. Edit and elaborate your answer to make it more informative and appropriate. Jan 21, 2014 at 11:17
  • I suppose for debugging purposes that is an option, but like the comment above suggest this isn't something I would put in production.
    – Index
    Jan 21, 2014 at 11:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.