In my php5-fpm/php.ini I have:
memory_limit = 512M However, after serving a few requests, ps uxa shows:
root 1130 0.0 0.3 339892 8064 ? Ss 05:29 0:00 php-fpm: master process (/etc/php5/fpm/php-fpm.conf) app 1131 0.6 38.9 1383692 798240 ? S 05:29 0:50 php-fpm: pool www app 1132 0.7 38.6 1383656 792736 ? S 05:29 0:57 php-fpm: pool www 798M RSS is quite beyond the limit. How is this possible? I could set a ulimit in the php-fpm init scripts, but first I would like to understand why it currently doesn't work.
Running php5-fpm 5.4.26 on Ubuntu 12.04 LTS.
update Thanks to OMG-1's answer below, I got it to work using this line in php-fpm.conf.
php_admin_value[memory_limit] = 256M Note: updating php.ini for 256M did result in an updated value according to phpinfo(), but not updated behaviour (even after reboot) -- I was still able to allocate 500M using the script below. So clearly a bug in PHP.
This was my test script, (thank you SO).
<pre> <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); function tryAlloc($megabyte){ echo "try allocating {$megabyte} megabyte..."; $dummy = str_repeat("-",1048576*$megabyte); echo "pass."; echo "Usage: " . memory_get_usage(true)/1048576; echo " Peak: " . memory_get_peak_usage(true)/1048576; echo "\n"; } for($i=10;$i<1000;$i+=50){ $limit = $i.'M'; ini_set('memory_limit', $limit); echo "set memory_limit to {$limit}\n"; echo "memory limit is ". ini_get("memory_limit")."\n"; tryAlloc($i-10); } ?> </pre>