I'm trying to run a Drupal installation on a shared hosting server. (I'm just subscribing to a provider - I don't own the box.)
I need to increase the PHP memory limit for my Apache server. I have tried
ini_set('memory_limit', '64M');
in settings.php (a file that is included in every request), but this causes Internal Server Error 500. If I take it out, I get this error:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes)...
Side question: 19456 is less than 33554432. Why is it saying that allowed size is exhausted?
I also tried putting this in on .htaccess:
php_value memory_limit 128M
This had no effect.
The error message you are getting :
Allowed memory size of 33554432 bytes exhausted (tried to allocate 19456 bytes)
Indicates that you are trying to allocate more than the 33554432 bytes you are allowed to use ; ie 32 MB :
; 33554432/1024/1024
32
It indicates that the allocation that failed was when PHP tryied to allocate 19 Kbytes ; but there had already been almost 32MB allocated -- those allocations did not fail, as their total was less than 32 MB.
The "19456 bytes" part of the error message is not what is really relevant : what is relevant is that your memory_limit
is set at 32 MB.
Considering the memory_limit
is some kind of security, it would be strange that your hosting provider allows you to change its value...
If you are on shared hosting, it would mean that anyone on the server could get any amount of memory they want... Which would not be that nice for the other users on the same server !
BTW : 32MB is actually a quite reasonable value -- I've never seen a server configured to allow more than 32 MB for a web application... And the default value for PHP 5.2 seems to be 16 MB, according to the manual.
(And I've been working with Drupal for a couple of months)
About the error 500, I don't have a lot of ideas... One possibility might be that the safe_mode
is activated, and that it doesn't allow setting the memory_limit at execution time.
The manual doesn't see to say much about that, but there is a bit of information under the max_execution_time
directive :
You can not change this setting with
ini_set()
when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini.
I suppose the same is true about memory_limit
; it would seem logical, anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With