Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a server where PHP memory_limit is 256M. Some scripts need more memory and does a ini_set('memory_limit', '256M'); but since Suhosin is installed and activated, I find this in log file

Sep 17 14:06:42 www-01 suhosin[28934]: ALERT - script tried to increase memory_limit to 536870912 bytes which is above the allowed value (attacker '127.0.0.1', file '/xxx/generate_docs.php', line 45) 

But suhosin is configured with

suhosin.memory_limit = 2048M

Both PHP memory_limit and suhosin.memory_limit values are confirmed by phpinfo(). Why PHP can't ask for more memory with this setup?

This script run fine for any memory limit value under 256M, but for a higher value I got the error and memory_limit don't change.

<?php
echo ini_get('memory_limit') . "<br>";
ini_set('memory_limit', '512M');
echo ini_get('memory_limit') . "<br>";
echo ini_get('suhosin.memory_limit') . "<br>";
echo "end<br>";

the output is

256M
256M
2048M
end
share|improve this question
    
As exmplained in the documentation the suhosin value is a hard limit, while php's value is a soft limit. See: hardened-php.net/suhosin/… –  symcbean Mar 31 at 13:15
    
My question is : if suhosin HARD limit is 2048, why I can't set php memory SOFT limit higher than 256M ? There is a clear bug when I set suhosin limit to 2048M. See my answer below. –  Cédric Girard Apr 1 at 13:39
    
Because the you can't set a soft limit higher than a hard limit by definition –  symcbean Apr 1 at 14:55
    
The HARD limit is 2048M, but the SOFT limit can't be higher than 256M. 2048M is greater than 256M or event 512M, in my mind. –  Cédric Girard Apr 2 at 11:49

1 Answer 1

up vote 0 down vote accepted

Alleluia. Asking a question help me to find the problem.

By setting suhosin.memory_limit to 1024 (2048 was for testing with an edge value), it run, and my script tells me

256M
512M
1024M
end

Same problem as http://stackoverflow.com/questions/9276212/php-settings-memory-limits-1024m-does-not-work/16854780#16854780 (same server, by the way)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.