Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP increase memory limit with environmental variable?

Tags:

php

A PHP script I am running (that is +x) is running out of memory:

Williams-MacBook-Air:pmtsystem williamentriken$ phpcpd --exclude core/ .
phpcpd 2.0.1 by Sebastian Bergmann.


Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32 bytes)     in phar:///usr/local/bin/phpcpd/src/Detector/Strategy/Default.php on line 78

Is it possible to increase the memory for just running this one instance of phpcpd?

like image 872
William Entriken Avatar asked Apr 29 '14 13:04

William Entriken


People also ask

What is the maximum PHP memory limit?

Increasing the PHP memory limit The default memory limit is 256M and this is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file.

What is the maximum amount of memory that a PHP script executed by Apache is allowed to allocate on this server?

By default, a PHP script can allocate up to 128 megabytes of memory.

What is $_ ENV in PHP?

Introduction. $_ENV is another superglobal associative array in PHP. It stores environment variables available to current script. $HTTP_ENV_VARS also contains the same information, but is not a superglobal, and now been deprecated. Environment variables are imported into global namespace.


1 Answers

Yes there is, try this:

php -d memory_limit=256M phpcpd --exclude core/ .

This will allocate 256Mb instead of your current 128Mb limit

like image 92
John Crawford Avatar answered Nov 14 '22 23:11

John Crawford