Skip to content

Should I increase the PHP memory_limit to match my VM memory_limit?

I have a doubt if I should do this or not. I have a VM with 4 GBs RAM from Linode. I want to optimize what I paid for and increase the default value of memory_limit in php.ini to allow my Laravel application to take much more than the default value.

sed -i -e 's/.*memory_limit.*/memory_limit = 4096M/g' /etc/php/7.1/fpm/php.ini

cat /etc/php/7.1/fpm/php.ini | grep memory_limit

/etc/init.d/php7.1-fpm restart

Will this help my Laravel application load faster?

Is there a limit of RAM that PHP will use ? even you set it to 4GB, they will still use a certain amount of RAM like .5 GB? Is it a myth or true ?



For most of the use cases, no you shouldn’t.

By design, PHP scripts doesn’t holds state. With an oversimplification here, that means: for each connection (request to the server) a new process with empty memory space will be started.

If you need full 4GB for each request to your application, boy.. you’re in big trouble!

You can read more about it, on this article:

User contributions licensed under: CC BY-SA
4 People found this is helpful