Koozali.org: home of the SME Server

Obsolete Releases => SME 9.x Contribs => Topic started by: brianr on July 25, 2017, 12:11:17 PM

Title: Memory size using php71 at command level.
Post by: brianr on July 25, 2017, 12:11:17 PM
I am running a rather heavy php program at the command prompt.  It runs fine under the default php (5.3.3), but when I run it under php71 (installing using the SCL contrib) it runs out of memory, giving me this:

PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in ....

where do I increase the memory allowed for php71?

Cheers Brian
Title: Re: Memory size using php71 at command level.
Post by: Daniel B. on July 25, 2017, 12:32:24 PM
php.ini is in /etc/opt/remi/php71/php.ini (which uses templates in Stéphane's contrib), but you can override it on the command line if needed:

Code: [Select]
php71 -dmemory_limit=512M /path/to/my_script.php
Title: Re: Memory size using php71 at command level.
Post by: mmccarn on July 25, 2017, 12:36:30 PM
PHP_Software_Collections#Usage (https://wiki.contribs.org/PHP_Software_Collections#Usage) implies that there is a db variable you use to set the MemoryLimit set for PHP71

Quote
[root@sme9b3dev64 ~]# config show php71
php71=configuration
   AllowUrlFopen=Off      #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M
Title: Re: Memory size using php71 at command level.
Post by: brianr on July 25, 2017, 03:54:34 PM
PHP_Software_Collections#Usage (https://wiki.contribs.org/PHP_Software_Collections#Usage) implies that there is a db variable you use to set the MemoryLimit set for PHP71

I'm not seeing the template for the php71 php.ini in /etc/e-smith/templates, is it somewhere else? or perhaps there is another action that translates the db variables into the php71 php.ini?
Title: Re: Memory size using php71 at command level.
Post by: Daniel B. on July 25, 2017, 03:56:59 PM
Looks like templates are in /etc/e-smith/templates/opt/remi/php71/root/etc/php.ini
Title: Re: Memory size using php71 at command level.
Post by: brianr on July 25, 2017, 04:01:09 PM
Looks like templates are in /etc/e-smith/templates/opt/remi/php71/root/etc/php.ini

so they are - thanks.
Title: Re: Memory size using php71 at command level.
Post by: brianr on July 26, 2017, 01:07:58 PM
for the record, here is how to change the memory_limit for php71:

# config setprop php71 MemoryLimit 1500M
# expand-template  /opt/remi/php71/root/etc/php.ini
# cat /etc/opt/remi/php71/php.ini | grep -i mem
memory_limit                           = 1500M
report_memleaks = On
Title: Re: Memory size using php71 at command level.
Post by: Daniel B. on July 26, 2017, 03:32:28 PM
This is only if you want to set this limit that high for everything. If you just need to rise the limit for a script, called from the command line, I still advise to set the override like this:

php71 -dmemory_limit=1500M /path/to/script.php

This way, standard PHP scripts ran by apache are still limited to a more reasonable value
Title: Re: Memory size using php71 at command level.
Post by: brianr on July 26, 2017, 03:43:50 PM
This is only if you want to set this limit that high for everything. If you just need to rise the limit for a script, called from the command line, I still advise to set the override like this:

php71 -dmemory_limit=1500M /path/to/script.php

This way, standard PHP scripts ran by apache are still limited to a more reasonable value

yes I can quite see that.