0

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> 

1 Answer 1

3

Maybe a duplicate of https://stackoverflow.com/questions/15962634/nginx-or-php-fpm-ignores-memory-limit-in-php-ini

I've never seen it work, when I put in memory limits in php.ini with php-fpm, I always use the php-fpm.conf and they are supposed to work.

Please verify that your master pool and using php_admin_value[memory_limit] = 512M works as expected?

1
  • Thanks! Indeed you are right: changing it in php.ini doesn't work, even though the changed value was represented correctly in phpinfo(). Commented Jun 17, 2015 at 20:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.