You are not logged in.

#1 2015-05-05 14:55:26

luken
Member
Registered: 2014-06-26
Posts: 37

memory_limit for php-cli

Hello!
Recently, when running php script from command line I got "Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 1058011 bytes)" this bothers me because I have set memory_limit for 1024M in my /etc/php/php.ini long time ago. I cannot see any separated configuration for php-cli . How can I increase this limit for php-cli?

Offline

#2 2015-05-05 16:38:12

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: memory_limit for php-cli

https://wiki.archlinux.org/index.php/PH … not_parsed

-edit-

php --ini should tell you, I guess, and Arch seems to use /etc/php/php.ini.

Last edited by lucke (2015-05-05 16:48:19)

Offline

#3 2015-05-06 10:42:58

luken
Member
Registered: 2014-06-26
Posts: 37

Re: memory_limit for php-cli

I created php-cli.ini yesterday. Output of "php --ini" is:

Configuration File (php.ini) Path: /etc/php
Loaded Configuration File:         /etc/php/php-cli.ini
Scan for additional .ini files in: /etc/php/conf.d
Additional .ini files parsed:      /etc/php/conf.d/xdebug.ini

But today I still encountered memory exhaustion error, like I would have 128M of memory only (I set everywhere 1024M). Any ideas how is this possible? hmm

Offline

#4 2015-05-18 19:59:53

2-d
Member
Registered: 2015-05-18
Posts: 6

Re: memory_limit for php-cli

Does this command return the right amounts for the local / global values?

php -i | grep memory_limit

Alternatively, is there anything in your code that might be setting the memory limit? For example:

ini_set("memory_limit", "128M");

Offline

#5 2015-05-18 20:03:16

luken
Member
Registered: 2014-06-26
Posts: 37

Re: memory_limit for php-cli

I tried "php -i | grep memory_limit" and it returned 1024M so the proper amount, even if I was getting exhaused error on 128 MB, which is weird. I bypassed the problem somewhat by putting ini_set("memory_limit", "1024M"); in my script - only then it started to act like it was really 1024M but reason why my memory was locked on 128M for CLI otherwise is still unknown hmm .

Offline

#6 2015-05-18 20:24:14

2-d
Member
Registered: 2015-05-18
Posts: 6

Re: memory_limit for php-cli

That's interesting.

I would bet there is something that is changing it locally for that script.  You can always place a "phpinfo();exit;" call into the heading of your script to see what the variables are.

Offline

Board footer

Powered by FluxBB