TL;DR - Don't bump your memory limits for the sake of it. For a standard PHP application like WordPress, 128MB is huge and should be enough for 90% of your needs.
However, there are a few important facts here:
PHP Memory Allocation is per-script/process
As per the PHP documentation for the
This sets the maximum amount of memory in bytes that a script is
allowed to allocate. This helps prevent poorly written scripts for
eating up all available memory on a server.
An important distinction to make is that this setting doesn't set the amount of memory that is available to all PHP processes - it sets the maximum available memory for one PHP process.
When Apache receives a request for a PHP page, it forks a PHP process, which dies as soon as its work is done. Any memory used during that request is then released back to the OS and the entire cycle starts again with the next request.
You should never have to tweak the
max_memory settings unless you are seeing "Out of memory" errors from PHP itself, and that generally only happens when you:
- Are working with large data-sets, which if you're running a WordPress website I extremely doubt.
- Have a memory leak or other problem which means that memory isn't being released back to the OS, and the correct response to this type of problem is to investigate the source problem, rather than just bumping limits.
If you're interested in tweaking for performance, you should look at the Apache
MaxClients and associated options within the
I would typically reserve 50MB for the kernel and other system processes, and dice up the rest for Apache and MySQL - there are various online guides detailing how to do this (which I strongly suggest that you read), but the general idea is:
top and check how much memory is used by your average Apache process (this is the
- Take your total memory, subtract the amount you want to reserve for other processes, and divide by the number above. This is the number of simultaneous connections that Apache can handle before it will need to turn clients away.
- Edit your Apache configuration and set the
MaxClients option to this number.
Note I mentioned simultaneous connections above, not visitors on your website. The two are not the same.