8

I just noticed that I am unable to increase my memory limit above the value configured in php.ini using ini_set(). I can, however, set it to any value below that and increase it to any other value below the one defined in the ini-file.

Does anyone know why this happens or how I could fix it?

soulmerge
  • 73,842
  • 19
  • 118
  • 155
  • Do you run your own server? Or do you have a hosted account? – Niels Bom Jan 29 '10 at 12:16
  • 4
    I believe memory_limit is a protected setting. It'd be senseless on a shared server to allow a script to use all the available memory. So if you're on a shared server, the way around is to ask your hosting company; on a dedicated server, it is to change that setting in your php.ini. – zneak Jan 29 '10 at 12:20
  • Zneak is right. You could ask your ISP to increase the limit for you. – Ben Fransen Jan 29 '10 at 12:23
  • I am aware of the fact that I could change it in the `php.ini` (it is my development machine), but the documented behaviour is that it is changeable at runtime and I want the higher limit for one or two files, not the whole project. Documentation of ini directive: http://de.php.net/manual/en/ini.core.php#ini.sect.resource-limits – soulmerge Jan 29 '10 at 12:28
  • don't ask to your ISP, ask to your hosting company! – wlf Dec 30 '12 at 12:47

4 Answers4

12

This is odd, according to the manual the memory limit can be set anywhere.

  • Do you have Suhosin installed? With Suhosin, it's possible to impose a global memory limit.

  • Do you have a .htaccess file lying around somewhere saying php_value memory_limit xyz?

  • Do you have Shell Fork Bomb protection activated? It can impose a global memory limit. See the SO question here. (I suppose this could be part of Suhosin).

  • What does your phpinfo() say concerning "local" and "global" memory_limit values?

  • How do you specify the limit, can you post a code snippet?

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
  • 3
    Many thanks, it was the suhosin patch. The default value of `suhosin.memory_limit` was causing this behaviour: http://www.hardened-php.net/suhosin/configuration.html#suhosin.memory_limit – soulmerge Feb 12 '10 at 11:26
1

Check your "safe_mode" setting - if enabled, it might prevent you from raising the memory_limit (allthough it's not documented).

1

you can not override memory limit on shared hosting accounts. that's simple. get a private (dedicated) hosting and you ask your provider to set it all the way up (although not recommended).

dusoft
  • 11,289
  • 5
  • 38
  • 44
  • The reason it is not possible on shared hosting accounts is that they normally have `safe_mode` enabled, which is not the case on my local machine. – soulmerge Feb 12 '10 at 11:20
0

PHP-FPM

There is an additional memory_limit in the pool config files (i.e. each pool may have a hard memory limit configured), for example

php_admin_value[memory_limit] = 256M

In that case, ini_set('memory_limit', $value) will return false for all values larger than the limit.

LSerni
  • 55,617
  • 10
  • 65
  • 107