• Resolved James

    (@en7jos)


    Hi,

    Could someone please clarify the meaning of the 3 memory limits that are shown under the PHP info section of the System Info tab in BPS Security?

    It says:
    —————————————-
    WordPress Admin Memory Limit: 256M
    WordPress Base Memory Limit: 64M
    PHP Actual Configuration Memory Limit: 128M
    —————————————-

    Is the ‘Admin Memory Limit’ the one set in the PHP.ini file for the server?

    The ‘Base Memory Limit’ is the one set in wp-config with “define(‘WP_MEMORY_LIMIT’, ’64M’);” – is that right?

    And where does the “Actual Configuration Memory Limit” come from?

    Thanks, James

    http://wordpress.org/plugins/bulletproof-security/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter James

    (@en7jos)

    Also meant to ask, which one (or more) of these memory limits actually defines what memory WordPress can use?

    Plugin Author AITpro

    (@aitpro)

    Very good question since this is kind of confusing. The PHP Configuration memory limit can be set in the Server’s php.ini file, a custom php.ini file, using the ini_set function and if your Server type allows php_flag and php_value to be used in .htaccess files then you can also set this in an .htaccess file. Every Host has a maximum memory limit that they allow on their Server.

    Your actual PHP Configuration Memory is the true memory limit that is set for your PHP Server or that your PHP Server actually allows. You can set the memory by using ini_set in any script or function, but whatever your Server allows is going to be the real PHP Configuration memory limit for your website/Server.

    So to be completely honest with you I am not sure if the WordPress Admin limit is really 256M or not. Logic says it cannot really be 256M if your Server’s maximum memory limit is 128M for example. Our Host’s maximum memory limit is 128M. When we set this to 256M in a php.ini file the Server just ignores this setting and remains at 128M because that is the maximum memory limit allowed on our Server, but the WordPress Admin Memory Limit is also 256M on our sites. πŸ˜‰

    Thread Starter James

    (@en7jos)

    Thanks, that’s helpful.

    After a bit of playing around, I’ve confirmed that the “WordPress Base Memory Limit: 64M” is set by the “define(‘WP_MEMORY_LIMIT’, ’64M’);” line in my wp-config.php file. Fine.

    Looks like I had the other two memoy limits the other way around: “PHP Actual Configuration Memory Limit: 128M” is the memory limit set by the line “memory_limit = 128M” in my php.ini file. (I’m on a VPS so have some control over this).

    But I cannot work out where on earth the “WordPress Admin Memory Limit: 256M” result is coming from.

    Any idea where this could be being set, or is it a default that WP is picking up from somewhere?

    Cheers, James

    Plugin Author AITpro

    (@aitpro)

    You will find this in these WP Core files and ini_set is of course used.
    /wp-includes/default-constants.php code line 28
    and
    /wp-admin/includes/file.php code line 535

    Plugin Author AITpro

    (@aitpro)

    I just thought of a totally logical explanation for the WordPress Admin Memory Limit 256M setting.

    Example Scenario: User A has his/her memory limit set too low and it is way below the maximum that the Server allows and also to low for WordPress to perform well or do essential things like install a new WordPress version update/upgrade. By choosing and setting 256M with ini_set this would actually increase the memory limit on that site to the maximum memory limit allowed, but would not go over the maximum allowed because that can’t be done using ini_set. So in my personal opinion 256M is the exact number/memory limit setting that I would also choose to ensure that there was plenty of memory to install or run something so that a catastrophic failed installation does not occur. Makes sense anyway.

    Thread Starter James

    (@en7jos)

    Great, thanks, so it is a default memory limit from the default-constants.php file!

    So in summary in case anyone else is interested:

    WordPress Base Memory Limit: 64M
    Is the normal WP memory limit which defaults to 40Mb (64Mb for a multi-site install) but can be changed by adding the following line to the top of the wp-config.php file:
    define(‘WP_MEMORY_LIMIT’, ’64M’);

    WordPress Admin Memory Limit: 256M
    Is a higher memory limit for the admin area which defaults to 256M but can be altered by adding the following line to the wp-config.php file:
    define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’);

    PHP Actual Configuration Memory Limit: 128M
    Is the PHP memory limit set in the php.ini config file on your server (which if you’re on a shared host you may not be able to change).

    I am assuming that the ‘Actual configuration memory limit’ is the true limit for the server setup and hence the other two memory limits can only ever really be less or equal to this. If they’re more they will just be ignored, I think?

    More details here:
    http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP

    Cheers, James πŸ™‚

    Plugin Author AITpro

    (@aitpro)

    Yep, your summation is correct and I had never really given the 256M WP Admin setting much thought before, but thinking about it from the perspective of why I would do this it became very obvious what the main purpose for this is. Also from personal experience I have found that the Server will not always return the actual php memory limit in standard php functions designed to retrieve this value and you end up with a blank value, which of course can be deadly – crashed website with a 500 Error if your script is depending on the Server returning a value – blank/empty value == crashed website. πŸ˜‰

    Not all empty/blank values would crash a site and of course you would have a condition that checked for an empty/blank value, but in the case of dealing with memory limit or anything relating to Server config then an empty/blank value can be a site killer.

    Thread Starter James

    (@en7jos)

    The reason the 256Mb limit was of interest to me as I use the “Really Simple WP Health” plugin as a simple way to check on server RAM and CPU usage whilst logged into the admin backend. This displays the RAM info along the lines of “Ram 7.09 of 256M (3%)” hence why I wondered where the 256 value was actually coming from. It’s obviously a bit meaningless if the server memory limit is set lower than this, so makes out that memory usage is lower (as a % of total available) that it actually is!

    A nice exercise is learning a little more about how WP works, even if it did take a couple of hours of head scratching to figure it out. πŸ™‚

    Plugin Author AITpro

    (@aitpro)

    Yep, you are correct that the check should be based on the actual true php server memory limit to get the percentage. πŸ˜‰ but the zinger is this. Some Servers for whatever reason do not return a value when you use this standard php function: get_cfg_var(‘memory_limit’). Not really sure why that is, but something I have noticed that does occur on occasion.

    Plugin Author AITpro

    (@aitpro)

    But of course if you used the WP Admin memory limit as a fallback condition and were checking for get_cfg_var first then you can say to yourself that you did the best you could with your code and the Server is at fault for not returning an accurate or any value. πŸ˜‰

    Thread Starter James

    (@en7jos)

    Makes sense, cheers. On the basis of what I’ve learned I’ve now set my memory limit in php.ini to 256Mb to match the default value that WP sets for WP_MAX_MEMORY_LIMIT. My reasoning being that I may as well give it what the WP team think it might need for installs etc. I’ve got the normal WP memory limit set to either 64Mb or 128Mb (depending upon the site size) via the wp-config.php setting.

    That makes sense, right?

    The WP admin area isn’t going to use the extra RAM unless it needs it, so if it is available then it might as well be allowed to use it now and then. I’ve kept the normal WP memory limit lower to limit the effect of any bad plugins etc.

    Cheers for your help, guess this can be closed out now πŸ™‚

    Plugin Author AITpro

    (@aitpro)

    Yep, logical on all points. πŸ˜‰

    Plugin Author AITpro

    (@aitpro)

    Resolving.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘PHP memory limits as reported in System Info’ is closed to new replies.