Function Documentation

WordPress Function Documentation Progress

wp-config.php Settings: Part 2

About WP_MEMORY_LIMIT

In WordPress 2.5, a new hard coded setting is added, which allows for increasing the memory limit. Few people always seem to have a problem where PHP exhausts all of the memory (usually 8MB) and PHP crashes, bringing down WordPress in the process.

By default, the memory is increased to 32MB, which is conservative or liberal depending on your hosts setting. Dreamhost has 128MB for PHP5, which is pretty crazy, but if a PHP program takes up all of that, then there is something seriously wrong with the application. WordPress should be able to run within 32MB on small and medium sized blogs with just the default caching.

This won’t solve all of the problems, because some hosts do not have memory limit setting enabled. In order for the increase to work, --enable-memory-limit had to be set during PHP installation and ini_set() has to be enabled (not part of the disabled_functions PHP INI setting). Nothing that WordPress, nor the user has control over. If --enable-memory-limit was not used, then the host can’t even increase the memory limit. Some hosts do disable the ini_set() function for security and PHP configuration purposes.

However, the good news is that unless you screwed up your PHP installation (and should reinstall and upgrade anyway) or on a crappy host, you should be okay and the increase will take affect.

Note: Don’t worry about the constant lowering the memory limit, because it won’t try to set the memory limit if the defined constant is less than what is already set in PHP.

Setting WP_MEMORY_LIMIT

In your wp-config.php file, insert the following:

define('WP_MEMORY_LIMIT', '32MB');

Just basically copy the above and the memory limit will be attempted to be set to ’32MB’. You can change ’32MB’ to any number of MiB in the format of a number, followed immediately by ‘MB’. So other examples are ’16MB’ (PHP5 default), ’64MB’

define('WP_MEMORY_LIMIT', '16MB'); // PHP5 default
define('WP_MEMORY_LIMIT', '67MB'); // Larger Blogs using default object cache. Just in case.

Criticisms

WordPress continues to work on improving the amount of memory that is required. It is impossible to optimize the WordPress Object Cache on large blogs and may never be. It is with that reasoning that the above addition is justified. If 32MB isn’t enough, just increase the memory limit and let the WordPress team know it failed.

About these ads

January 31, 2008 - Posted by | Advanced User Manual | , , ,

1 Comment »

  1. It needs to be “define(‘WP_MEMORY_LIMIT’, ’32M’);”, M not MB in the end.

    TT

    Comment by tt | December 12, 2008 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: