dsgs8208 2019-07-18 08:32
浏览 1003

Composer内存不足 - 需要替代方法来增加PHP memory_limit

I'm trying to install an extension on a client's Magento 2 via Composer, but I'm running into the old PHP out of memory error.

My client is hosted with Bluehost, which unfortunately means I can't just go in and change the memory_limit in php.ini, as it's read only, and their cPanel MultiPHP INI Editor doesn't affect SSH. My client has been in touch with Bluehost, and they were told Bluehost doesn't allow SSH memory_limit to be altered, HOWEVER, my client only recently had to install a different extension, which required the memory_limit to be increased, but they did it themselves and they can't remember what commands they used or the file they edited.

I can confirm Composer is installed properly on the server, since I can run the command composer require path/to/extension. This just results in the out of memory error.

Running the command COMPOSER_MEMORY_LIMIT=-1 composer require amasty/advanced-review results in the same error:

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

Fatal error: Out of memory (allocated 809508864) (tried to allocate 4096
bytes) in phar:///opt/cpanel/composer/bin/composer/src/Composer
/DependencyResolver/RuleSetGenerator.php on line 126

Anyone have any suggestions as to what I can do to get things working properly?

  • 写回答

1条回答 默认 最新

  • douyi1779 2019-07-18 08:58

    You aren't running into the PHP memory limit. If that where the case the error message would be something like "Allowed memory size of N bytes exhausted". The failing mmap call suggests that you are running out of physical memory.

    Either upgrade the host or do the dependency updates on another machine with more memory. To do so

    1. Copy composer.json and composer.lock to a machine with sufficient memory
    2. Run composer require amasty/advanced-review --no-scripts --ignore-platform-reqs on that machine
    3. Copy the updated composer.json and composer.lock files back to the Bluehost machine
    4. Run composer install on the Bluehost machine

    This works because composer install doesn't do any complex dependency resolution and thus requires little memory.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥65 LineageOs-21.0系统编译问题
  • ¥30 关于#c++#的问题,请各位专家解答!
  • ¥15 App的会员连续扣费
  • ¥15 不同数据类型的特征融合应该怎么做
  • ¥15 用proteus软件设计一个基于8086微处理器的简易温度计
  • ¥15 用联想小新14Pro
  • ¥15 multisim中关于74ls192n和DSWPK开关仿真图分析(减法计数器)
  • ¥15 w3wp,exe 中发生未处理的 Microsoft ,NETFramework 异常。
  • ¥20 C51单片机程序及仿真(加减器)
  • ¥15 AQWA | 水动力分析 二阶波浪力