PHP : settings memory_limits > 1024M does not work

Cédric Girard picture Cédric Girard · Feb 14, 2012 · Viewed 366.9k times · Source

For bads reasons I need to set memory_limits higher than 1G for a directory, but on my PHP 5.2.17 on Lenny server when I put for example 2048M I get only the php.ini default value (256M).

PHP run as an apache module, phpinfo give us (for the directory)

memory_limit    1024M   256M
suhosin.memory_limit    0   0

Is there a limitation due to apache module, or PHP conf? I know the server only have 4G of RAM, it's just a special script.

Answer

kingmaple picture kingmaple · Feb 14, 2012

How are you trying to set the memory limit? phpinfo() shows current PHP reserved memory limit, this is what is available due to php.ini having that set as a memory limit

Writing this to Apache .htaccess in your script directory might work, if your server supports setting PHP commands through .htaccess:

php_value memory_limit 2048M

Since it may be possible that .htaccess commands for setting PHP values are turned off. Then you can also try this from PHP code:

ini_set('memory_limit', '2048M');

If this doesn't work and .htaccess also doesn't work, then you need to contact server administrators.