Search code examples
phpmysqlwordpress

PHP Memory limit not taking effect in normal php scripts


I've assigned the memory limit of php to 999m so it appears in phpinfo like

memory_limit 999M 999M

when I use phpinfo(); to show it.

Unfortunately when I try to run a fairly large script, it seems like the limit is 256M

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 40 bytes) in /xxx/wp-includes/wp-db.php on line 1403

Anyone have any ideas why or what I can do to increase the limit (and have it actually work)

If it helps I'm running centos5 32bit and with php running in fcgi mode


Solution

  • Create a php file called test.php, put inside:

    <?php
    phpinfo();
    ?>
    

    Check for "Configuration File (php.ini) Path" and "Loaded Configuration File" to see the correct php.ini path. Edit php.ini and search for memory_limit and set it to:

    memory_limit = 999M
    

    Check if you have more than one occurrency of memory_limit into the php.ini file. In the case, delete it.

    Stop apache, and then restart it (apachectl restart | apachectl graceful | kill -1 are not ok. Stop, then start).

    Recheck test.php to see if the new parameter got acquired.