Search code examples
phpmemory-limit

setting memory_limit to 2048M but i keep getting 256M error


I am making a plugin for WP, in that plugin there is backup feature that need to run for large period of time, this part also require large amount of memory limit.

So i have set ini_set('memory_limit', '2048M');, ini_set('max_execution_time', 10000); in my script and define( 'WP_MEMORY_LIMIT', '2048M' ); in WP config file.

However i keep on getting : Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes)

Is it a possibility that the hosting company has a certain limit that i cannot change while run-time ?

Thanks in advanced.


Solution

  • It is very strange. See my output of phpinfo():

    enter image description here

    Hosting provider has raised my limit to 128M (it is not me who set it to 128M), and in reality I have 128M available. According to my understanding of Master Value overriding the Local Value, I should have only 64M.

    What is most strange, that neither of these values are affected by ini_set('memory_limit', '32M');!!

    Using phpinfo is easy, just place the following php file to your server:

    <?php
        phpinfo();
    ?>