If WordPress show a message error “Fatal error: Allowed memory size”, for example to add a picture or installing a new plugin in your wordpress account. This is because you are exceeded memory limit reserved to PHP and you need increase it. I propose different solutions.
Solution at WordPress error «Fatal error: Allowed memory size»
Login via FTP client (Filezilla for example) to your hosting account and try to solve the problem
with one of the following solutions:
- Edit wp-config.php file, the file is in the blog root folder and add at the end define(‘wp_memory_limit’,’XXM’); where XXM is the amount of memory you need:
/** WordPress absolute path to the WordPress directory. */if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */require_once(ABSPATH . 'wp-settings.php'); define('wp_memory_limit','80M');
If you don’t solve the problem, try with define(‘WP_MAX_MEMORY_LIMIT’, ‘XXM’)
/** WordPress absolute path to the WordPress directory. */if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */require_once(ABSPATH . 'wp-settings.php'); define('WP_MAX_MEMORY_LIMIT', '80M');
- Edit .htaccess file, this file is in the blog root folder (probably hidden)
and add the code line php_value memory_limit XXM:<IfModule mod_rewrite.c> php_value memory_limit 64M RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
- Try to increase a memory specified in the default-constants.php file,
this file find it in wp-includes folder. Edit line 9 where in the example
is define(‘WP_MEMORY_LIMIT’, ’48M’); and especified increasing the memory you need:function wp_initial_constants() { global $blog_id; // set memory limits if ( !defined('WP_MEMORY_LIMIT') ) { if( is_multisite() ) { define('WP_MEMORY_LIMIT', '64M'); } else { define('WP_MEMORY_LIMIT', '48M'); } } if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) { define( 'WP_MAX_MEMORY_LIMIT', '256M' ); }
If your wordpress install is multisite, then modify line 7 where in the example is define(‘WP_MEMORY_LIMIT’, ’64M’);