1

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
4
  • 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, 2014 at 13:15
  • 1
    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. Apr 1, 2014 at 13:39
  • Because the you can't set a soft limit higher than a hard limit by definition
    – symcbean
    Apr 1, 2014 at 14:55
  • 1
    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. Apr 2, 2014 at 11:49

1 Answer 1

1

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 https://stackoverflow.com/questions/9276212/php-settings-memory-limits-1024m-does-not-work/16854780#16854780 (same server, by the way)

1
  • Sorry, but I still don't understand why that wasn't working with your previous suhosin.memory_limit value of 2048M.. Could you please explain? PHP memory_limit default is 256M, you're trying to set it to 512M, which is still lower than suhosin.memory_limit 2048M limit, so that should have worked.
    – 4wk_
    Mar 22 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .