If you get memory exhausted fatal errors on your WordPress blog, maybe its time to increase memory limit for PHP. In this post, you will find various ways to increase memory limit for WordPress using PHP and htaccess files.

When PHP scripts get complex they require more memory than regular PHP files. When PHP is lower than the required limit, you may start getting errors like this:

Sample Error Message:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 7680 bytes) in /nfs/[…]/mnt/[…]/domains/[…]/html/wp-includes/[…].php on line 314

To resolve this error, you can increase your PHP memory limit using one of the following options

Increasing PHP Memory Limit Using wp-config.php File

If you have access to wp-config.php, just define new memory limit using:

define('WP_MEMORY_LIMIT', '96M');

Increasing PHP Memory Limit Using php.ini File

PHP Memory limit is first set inside the php.ini file. If you have access to your php.ini, you can change default limit to a new one.

memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)

Increasing PHP Memory Limit Using .htaccess Files

If you don’t have access to php.ini file, you can also use .htaccess files to define new PHP limit.

php_value memory_limit 64M

Increasing PHP Memory Limit Using a Plugin

For users that don’t have file access at all, WordPress released a plugin called Memory Bump to increase the memory limit. However, it is not updated for more than 2 years now. Still worth a try if you can’t access files on your hosting server.