LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   CentOS (https://www.linuxquestions.org/questions/centos-111/)
-   -   php - changing memory size limit (https://www.linuxquestions.org/questions/centos-111/php-changing-memory-size-limit-4175594349/)

robertkwild 11-28-2016 03:42 AM

php - changing memory size limit
 
hi all,

i have found where you can change the memory size here -

; Maximum amount of memory a script may consume (128MB)
; http://www.php.net/manual/en/ini.cor...i.memory-limit
memory_limit = 128M

but i dont know what to set it to

i need to change it as when i run a script that uses php it complains it runs out of memory

thanks,

rob

MensaWater 11-28-2016 08:29 AM

Ideally the php application should have some indication of acceptable limits.

For example this Drupal page talks about php for their setup:
https://www.drupal.org/docs/7/managi...-memory-limits

Failing that a usual tuning technique is to do increases until it works without complaint. e.g. Double to 256m, restart and see if that helps. If not try 512m and repeat. Once you find an upper level that works you can try intermediate values if allowed.

Obviously there is a physical limit to this kind of thing. You would not want to set PHP to take ALL the physical memory (e.g. 8 GB) in your system even if this app is the only thing you intend to run as it wouldn't allow any memory for system processes. If you're running other apps you'd want to make sure you're not allocating so much memory to PHP that those other apps are starved for memory.

Also some programs are poorly written and/or have memory leaks (e.g. much Java) so it is possible the app would simply use as much memory as you have and then still complain. If this is the case, the fix is to adjust the app itself so it doesn't have that flaw any longer.


All times are GMT -5. The time now is 03:15 AM.