Ramblings from MostlyChris

Tech stuff and a bit more

Browsing Posts in Pear

I was installing APC on a server and ran across this error:

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /usr/share/pear/PEAR/PackageFile/v2/Validator.php on line 1831

One would assume that fixing this would be to edit the php.ini file and change the memory settings. However, that is not the case here. In order to fix this, you would edit /usr/share/pear/pearcmd.php and add the following line to the very top of the file (after the opening PHP tag):

@ini_set('memory_limit', '16M');

Adjust the memory limit to what you need. For good measure, I remove that line once I am done installing whatever it is I need to install.

Recently, I ran into an error while attempting to install a PECL package on a Redhat 5.3 64bit server.

—-
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 23040 bytes) in /usr/share/pear/PEAR/Builder.php on line 263
—-

I checked the memory limit setting in /etc/php.ini and it was set for 16M so that wasn't the problem. This is happening because PECL requires more memory on a 64bit box than a 32bit one. Incidentally, this works fine on 32bit OS's.

There are a couple of ways to get around this. The first would be to place the following at the top of the /usr/share/pear/pearcmd.php file:

ini_set('memory_limit', '16M');

Alternatively, you could could add the following to /usr/bin/pecl:

-d memory_limit=16M

16M should be plenty. However, if you still don't have enough memory then up the number to 32M. If that isn't enough, something else is going on.