Pear升级遇“Allowed memory size exhausted”错误的解决方法求助
Hey there, let's work through this PEAR upgrade memory problem together. The error message shows you're hitting a 128MB limit (134217728 bytes = 128MB), which means the memory_limit=4G you set isn't being picked up by the PHP process that PEAR is using. Here's how to get this sorted:
Step 1: Identify the correct PHP config file PEAR uses
First, let's confirm exactly which PHP binary PEAR is calling, and which php.ini file that binary loads:
- Run this command to get PEAR's PHP path:
pear config-get php_bin - Then use that path to check the loaded config file (replace
/path/to/phpwith the output from the first command):/path/to/php -i | grep "Loaded Configuration File"
This will show you the exact php.ini file affecting your PEAR commands—most systems use separate configs for web PHP and CLI PHP, so you probably edited the wrong one earlier.
Step 2: Update the correct php.ini setting
Open the php.ini file you found in Step 1, locate the memory_limit line, and set it to your desired value:
memory_limit = 4G
If you want to remove the limit entirely just for the upgrade (not recommended for long-term use), you can set it to:
memory_limit = -1
Save the file—CLI PHP changes take effect immediately, no restart needed.
Step 3: Quick fix - force memory limit in the command
If you don't want to edit the config file right now, you can override the memory limit on the fly when running the upgrade:
php -d memory_limit=4G /usr/local/pear/bin/pear upgrade
This forces the PHP process running PEAR to use 4GB of memory for just this single command.
Step 4: Check for hardcoded limits (rare case)
In very rare scenarios, the PEAR Registry.php file might have a hardcoded memory limit. If the above steps don't work, quickly check line 417 of /usr/local/pear/share/pear/PEAR/Registry.php to see if there's an ini_set('memory_limit', ...) call overriding your config. If so, you can comment it out temporarily for the upgrade.
After trying these steps, re-run pear upgrade—it should now use the higher memory limit you've set.
内容的提问来源于stack exchange,提问作者Mike Croteau

