Can't increase PHP memory limit past 150M



Hi, I’m trying to increase my php memory limit. I have set the following code in my phprc file:

[php]; {{{ The following lines were automatically added by DreamHost
; }}} That’s all from DreamHost

log_errors = 1
error_reporting = E_ALL
error_log = /home/paracadute/php.log

memory_limit = 500M

But I still encounter the following error at runtime:

PHP Fatal error: Allowed memory size of 157286400 bytes exhausted (tried to allocate 20680 bytes) in …

Does anyone know why the memory limit is not increasing to 500M? Does dreamhost limit this elsewhere?



Probably a hard limit. Does phpinfo() indicate the change is being applied?

<?php phpinfo(); ?>


In fact, phpinfo() does show the change as applied. Hmmm…


Hard limit is kicking in then.

Considering you’re on VPS or Dedi, I’d contact official Support and ask if they have an alternative system you can be migrated to.


The Suhosin security extension we have installed for PHP 5.3 can get kind of weird about changing the memory limit. This is kind of unfortunate, but it’s too late in the release cycle for us to change it now. Can you try switching to PHP 5.4, if possible, and see if the issue persists?


Is there a particular reason you need so much memory for each PHP process? It may be better in the long run to identify whether you’re doing something that could be done differently; buffering files in memory is the usual culprit, instead of processing them as a stream. Also forgetting to use unset to clear variables you’re no longer using so their memory can be freed up.

Of course there are reasons you may need to, but it seems incredibly high for a PHP application.