Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"php --help" results in "PHP memory exhausted" error on Ubuntu

PHP Fatal error: Allowed memory size of 262144 bytes exhausted (tried to allocate 523800 bytes) in Unknown on line 0

Same thing occurs with "php5 --help"

I have already researched this and read that I should: 1) increase the memory limit in php.ini - it's at 128MB in all instances of php.ini - should be enough to run php cli help 2) make the script more memory efficient - obviously doesn't apply to --help

Please help if you can ?

like image 965
Mark Soper Avatar asked Dec 03 '22 09:12

Mark Soper


2 Answers

Check the php.ini file for PHP CLI (/etc/php5/cli/php.ini).

Make sure the memory_limit declaration has its units set:

memory_limit = 32M

not

memory_limit = 32

It fixed it for me. I hope it works for you too.

like image 107
losttime Avatar answered Dec 27 '22 01:12

losttime


I am assuming you're on a recent Linux install. I'm using Ubuntu, but any Debian like Linux distribution will be similar and other distribution won't have a lot of differences either.

In /etc/php5/ I have the following configuration directories:

root@delphic:/etc/php5# ls -la
total 20
drwxr-xr-x  5 root root 4096 2011-01-15 00:52 .
drwxr-xr-x 92 root root 4096 2011-01-15 00:51 ..
drwxr-xr-x  2 root root 4096 2011-01-05 10:55 apache2
drwxr-xr-x  2 root root 4096 2011-01-15 00:52 cli
drwxr-xr-x  2 root root 4096 2011-01-15 00:51 conf.d
root@delphic:/etc/php5# cd cli
root@delphic:/etc/php5/cli# ls -al
total 76
drwxr-xr-x 2 root root  4096 2011-01-15 00:52 .
drwxr-xr-x 5 root root  4096 2011-01-15 00:52 ..
lrwxrwxrwx 1 root root     9 2011-01-15 00:52 conf.d -> ../conf.d
-rw-r--r-- 1 root root 67457 2011-01-12 19:51 php.ini 
root@delphic:/etc/php5/cli# grep memory php.ini 
; Maximum amount of memory a script may consume (128MB)
; http://php.net/memory-limit
memory_limit = -1

Are you sure you changed the CLI memory limit as well?

If you're on a shared hosting service, you will have to ask their support for help on changing the limits or have them find out why php is consuming so much memory even on the command line.

like image 41
ramdyne Avatar answered Dec 27 '22 02:12

ramdyne