Support » Plugin: Server IP & Memory Usage Display » Bug: incorrect server total MBs, and measure % against WP LIMIT instead

  • I started to use the plugin (v2.1.0) today on my server and noticed a little bug with the total amount of MBs available on the server.

    The hosting package I use comes with 2GB and this translates into:

    Memory: 12 of 2147483648 MB (0%) | WP LIMIT: 384 MB

    …instead of…

    2147483648 / 1024 / 1024 = 2048 MB = 2 GB

    Also – wouldn’t it make more sense when the WP LIMIT is shown there instead so the usage is a % of the WP LIMIT?

    So like: Memory: 12 of 384 MB (WP LIMIT) (0%) | Server Total: 2048 MB

    —-

    To fix the bug:

    Line 46 should be changed into:
    $this->memory['limit'] = (int) ini_get('memory_limit') / 1024 / 1024;

    And perhaps change line 55 into:
    $this->memory['percent'] = round ($this->memory['usage'] / $this->memory['limit'] * 100, 1);
    To show 1 decimal which would be useful in case of smaller percentages.

    • This topic was modified 3 months, 2 weeks ago by Steven.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author apasionados

    (@apasionados)

    Hi Steven,

    On some shared hosting this is a problem but on others it isn’t. On VPS or dedicated servers there is no problem. So we haven’t found a way to know if the memory amount show be divided by 1024 / 1024 or not. If we divide it always, on the mayority of WordPress installations the memory amount will not be correct anymore. Nevertheless we will think about it again or maybe you have an idea that can help us find a solution.

    We reference the memory amount to the PHP memory limit because the WordPress memory limit doesn’t seem to have a real impact on a WordPress installation. We have done several tests and always the real limitation has been the PHP memory limit and not the WordPress memory limit.

    Best regards from Spain.

    I understand – always a problem when different server configurations result in different representation of a data element. In my case the 2GB is correct for the hosting package and the WordPress installation is using less than the full available amount of it.

    Since version 2.5 the default memory limit for WordPress is set to 40MB or 64MB for a multisite installation). It’s also in the WordPress documentation but this was my first hit: https://www.cloudaccess.net/fresh/blog/entry/2016/06/01/wordpress-memory-limits.html

    So from that point if would make sense to just look at both

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

    when you do the calculations instead of the available capacity on the server.

    I’m not sure how much work it is to get hold of the values when defined in either the php.ini file ( memory_limit = 256M ) or the .htaccess file ( php_value memory_limit 256M ).

    • This reply was modified 3 months, 1 week ago by Steven.
    • This reply was modified 3 months, 1 week ago by Steven.
    Plugin Author apasionados

    (@apasionados)

    Hi @stgoos,

    As we wrote in our first reply to your review, we reference the memory amount to the PHP memory limit because the WordPress memory limit doesn’t seem to have a real impact on a WordPress installation.
    If the PHP memory is higher than the WordPress memory limit, and the WordPress installation needs more memory it will use all the memory defined in the PHP memory settings, ignoring the lower WordPress memory limit. At least that’s our experience. And that’s why we reference to the PHP memory limit.

    Best regards from Spain.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this review.