WordPress.org

Ready to get started?Download WordPress

Forums

WP-ServerInfo
PHP memory_limit stuck at 256M (14 posts)

  1. islandcastaway
    Member
    Posted 3 years ago #

    I'm using WP 3.1 and it seems that the plugin "wp-serverinfo"'s PHP memory_limit is stuck at 256M.
    I have my memory limit set @ 400M but it does not recognize it.

  2. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    If it reads at 256M, means it is 256M as it is reading directly from the config.

  3. islandcastaway
    Member
    Posted 3 years ago #

    wp-config.php = define('WP_MEMORY_LIMIT', '400M');
    php.ini = memory_limit = 400M
    .htaccess = php_value memory_limit 400M
    wp-overview plugin = shows 400M
    phpinfo(); = shows 400M

    What config are you taking about? It seems to be fine except this plugin.

    I found this thread that states something may have changed in 3.0:
    http://wordpress.org/support/topic/wp3-exeed-256-memory-limit

  4. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Hmm that is wierd, there is a PHP info as well in WP-ServerInfo. What does it says?

    The settings is reading off PHP function. You can do a <?php echo ini_get('memory_limit'); ?> in a php file and point your browser to it and see what it says. That is the code WP-ServerInfo use.

    Ref: http://php.net/manual/en/function.ini-get.php

  5. islandcastaway
    Member
    Posted 3 years ago #

    <?php echo ini_get('memory_limit'); ?> also shows the correct 400M.

    Your plugin is the only one stuck at 256M.

    Maybe take a look at what wp-overview(lite) did to update their plugin.

  6. islandcastaway
    Member
    Posted 3 years ago #

    They use <?php echo WP_MEMORY_LIMIT?> and it works

  7. islandcastaway
    Member
    Posted 3 years ago #

    I changed line 622 from:
    echo '<li>'. __('Memory Limit', 'wp-serverinfo').': <strong>'.format_php_size(get_php_memory_limit()).'</strong></li>';

    to
    echo '<li>'. __('Memory Limit', 'wp-serverinfo').': <strong>'.WP_MEMORY_LIMIT.'</strong></li>';

    and it still shows 256M so there is something else in your plugin.

    It has to be something with 3.# multi site's way of looking it up

  8. islandcastaway
    Member
    Posted 3 years ago #

    Doh!

    I found another place, line 144

    changed <td><?php echo format_php_size(get_php_memory_limit()); ?></td>

    to
    <td><?php echo WP_MEMORY_LIMIT; ?></td>

    and tada, it works now!

  9. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    That is weird, I can't reproduce this problem on my end. I tried 400M and it works for me.

    The only difference is that I formatted the output after reading it.

    Could you try this piece of code for me?


    <?php
    function format_filesize($rawSize) {
    if($rawSize / 1099511627776 > 1) {
    return number_format($rawSize/1099511627776, 1).' TiB';
    } elseif($rawSize / 1073741824 > 1) {
    return number_format($rawSize/1073741824, 1).' GiB';
    } elseif($rawSize / 1048576 > 1) {
    return number_format($rawSize/1048576, 1).' MiB';
    } elseif($rawSize / 1024 > 1) {
    return number_format($rawSize/1024, 1).' KiB';
    } elseif($rawSize > 1) {
    return number_format($rawSize, 0).' bytes';
    } else {
    return 'unknown';
    }
    }
    function format_php_size($size) {
    if (!is_numeric($size)) {
    if (strpos($size, 'M') !== false) {
    $size = intval($size)*1024*1024;
    } elseif (strpos($size, 'K') !== false) {
    $size = intval($size)*1024;
    } elseif (strpos($size, 'G') !== false) {
    $size = intval($size)*1024*1024*1024;
    }
    }
    return is_numeric($size) ? format_filesize($size) : $size;
    }

    echo format_php_size(ini_get('memory_limit'));
    ?>

  10. islandcastaway
    Member
    Posted 3 years ago #

    That returns "400.0 MiB" :)

    Are you testing on a multi-site installation?

    That thread I posted before hints at that as the source.

  11. Lester Chan
    Member
    Plugin Author

    Posted 3 years ago #

    Weird, nope I am testing on a single installation. I have not tested and used WPMU before =p

  12. islandcastaway
    Member
    Posted 3 years ago #

  13. islandcastaway
    Member
    Posted 3 years ago #

    I changed the 2 core files in the patch to show 400M instead of 256M and that still didn't fix it.

  14. islandcastaway
    Member
    Posted 3 years ago #

    TADA,

    /wp-admin/admin.php

    line 109

    @ini_set( 'memory_limit', apply_filters( 'admin_memory_limit', '256M' ) );

    I changed that and now it works :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic