fbpx

WordPress Memory Management

wordpress memory management

Is your website running slowly, are there sometimes out of memory errors on your site like this one? You may need some WordPress memory management.

Fatal error: Out of memory (allocated 11272192) (tried to allocate 77824 bytes)

WordPress Memory Management

What is WordPress memory management I hear you cry and why should it effect me?

Hosting companies want your to use as few of their resources as possible, and often the default configuration you are given, is not enough to run a WordPress site effectively.

I would say the minimum you need is 128MB with a view to something nearer 1256MB for ecommmerce or busy sites.

What Uses Memory

All of the modules that make up your WordPress site, and the more you have the more memory is used.

The WordPress core service take memory, plugins take memory , your theme takes memory, making calls to the database takes memory and the more of these processes (read more site visitors) you spawn the more memory is used.

How Much Memory & How Is It Used

My favourite way to view memory limits and usage is to install this plugin:

https://en-gb.wordpress.org/plugins/tpc-memory-usage/

Once installed it provides a useful admin area widget that shows maximum available memory and how much is currently used.

It also has a useful alerting tool that sends an email if you get spikes in memory usage.

How To Fix The Issue

Simple, increase available memory to WordPress.  You can do this in a number of ways.  Your results may vary with these techniques depending upon which company you host with.

Increase Memory Limit Plugin

The easiest way to increase available memory is with this plugin, install it and set the new memory limit.  I’ve had mixed results with this plugin not all hosts will work with this method.

https://wordpress.org/plugins/change-memory-limit/

Edit WP-CONFIG.PHP

In the root of your site is a file called wp-config.php, this is a configuration file for WordPress, and one of the configuration options is to set

Connect to your site using FTP or the file manager in your hosting dashboard, navigate to the root of your site and edit wp-config.php, and add the following line

define(‘WP_MEMORY_LIMIT’, ‘128M’);

WARNING – you can break your site if you edit this file incorrectly

Edit PHP.INI

The last method I’m going to talk about is editing a file called php.ini.  This file contains the configuration for php the scripting language WordPress uses, and one of the configuration options is to set memory.  PHP.ini is held in different directories based upon your hosting, most often it is in the root directory.

Again, connect to your site using FTP or the file manager in your hosting dashboard, navigate to the root of your site and edit php.ini , and add the following line:

memory_limit = 128M;

If In Doubt

Contact your hosting company they can advise you on the best way to increase available memory.

Wrap Up

This is a very common problem and is caused by hosting companies being stingy with their resources, check what memory is available to you and increase it to at least 128MB.

Photo Credit: PinkPersimon via Compfight cc

Leave a Reply

Your email address will not be published. Required fields are marked *