1

Running a dedicated managed server with 2 GIGS of RAM. How much memory can I define in wp-config.php

Currently I have

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

I suspect a plugin that resizes images when they are being uploaded, that might cause the server to crash, but I am not sure yet.

How can I allocate more memory for this plugin to operate?

Many thanks Andy

1
  • 1
    Instead of 256M write 2048M ? Memory limits above 256 only work after WP ver 3.2 for the wp-config.php
    – Wyck
    Dec 6, 2012 at 19:55

2 Answers 2

1

Try one (or more) of the below methods to increase the memory allicated by PHP. First try increasing the limit to 64MB, and if that fails use 96M.


You can define the WP_MEMORY_LIMIT constant in wp-config.php:

Increase PHP Memory to 64MB

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

Increase PHP Memory to 96MB

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

You can also change the setting in your .htaccess file:

Increase PHP Memory to 64MB

php_value memory_limit 64M

Increase PHP Memory to 96MB

php_value memory_limit 96M

You can add a line to wp-config.php telling PHP to increase the memory limit:

Increase PHP Memory to 64MB

ini_set('memory_limit','64M');

Increase PHP Memory to 96MB

ini_set('memory_limit','96M');

This is not the most preferred method, and you should try the other methods first.

4
  • 1
    I agree with everything except using ini_set(), do it in your php.ini or .htaccess, never in your code! Dec 7, 2012 at 11:06
  • ok, I am not a server expert but i am just moving to a dedicated managed server with 12 GIGS of RAM.... What setting should I put in wordpress and where it's best to do that? :) Dec 7, 2012 at 17:57
  • @theMojoWill I agree that the other methods are preferable - however, not everyone has access to .htaccess or php.ini.
    – shea
    Dec 7, 2012 at 20:38
  • If you don't have access to .htaccess or php.ini then I doubt that the host will allow ini_set() Dec 10, 2012 at 15:07
1

256MB is a pretty decent limit to start with. Bear in mind that PHP's memory limit is different from PHP's max file upload size.

ini_set( 'memory_limit', '128M');
ini_set( 'upload_max_size' , '10M' );
ini_set( 'post_max_size', '10M');
  • memory_limit is how much memory a PHP process can use at one time. This includes the script processing, handling operations, etc. Generally, if you have to take this value really high, you're doing something very wrong. Most servers can probably survive on 256MB with no problem.
  • upload_max_size is the maximum file size a file uploaded and passed to PHP may be. This, in-turn, determines the WordPress maximum file size.
  • post_max_size sets the max size of post data allowed. From the PHP Manual:

This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. Generally speaking, memory_limit should be larger than post_max_size.

Understanding these directives and their differences will help you better configure your server to address the problems you are solving. Good luck!

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.