【问题标题】:Allowed memory size of # bytes exhausted when deploying Sylius application on Heroku在 Heroku 上部署 Sylius 应用程序时允许的 # 字节内存大小耗尽
【发布时间】:2019-12-07 11:21:38
【问题描述】:

我正在尝试将 Sylius 应用程序部署到 Heroku。构建过程失败并出现以下错误:

...

remote:          - Installing doctrine/doctrine-migrations-bundle (2.1.2): Loading from cache
remote:          - Installing doctrine/doctrine-fixtures-bundle (v2.4.1): Loading from cache
remote:          - Installing sylius/sylius (v1.6.4): Loading from cache
remote:          - Installing symfony/dotenv (v4.4.1): Loading from cache
remote:        Generating optimized autoload files
remote:        ocramius/package-versions:  Generating version class...
remote:        ocramius/package-versions: ...done generating version class
remote:        Executing script cache:clear [KO]
remote:         [KO]
remote:        Script cache:clear returned with error code 1
remote:        !!
remote:        !!   // Clearing the cache for the prod environment with debug
remote:        !!   // false
remote:        !!
remote:        !!  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /tmp/build_f92eb0b1353ebcf9e35e6d53f7853796/vendor/twig/twig/src/Node/Node.php on line 168
remote:        !!  PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /tmp/build_f92eb0b1353ebcf9e35e6d53f7853796/vendor/composer/ClassLoader.php on line 444
remote:        !!
remote:        Script @auto-scripts was called via post-install-cmd
remote:
remote:  !     ERROR: Dependency installation failed!
remote:  !
remote:  !     The 'composer install' process failed with an error. The cause
remote:  !     may be the download or installation of packages, or a pre- or
remote:  !     post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
remote:  !     in your 'composer.json'.
remote:  !
remote:  !     Typical error cases are out-of-date or missing parts of code,
remote:  !     timeouts when making external connections, or memory limits.
remote:  !
remote:  !     Check the above error output closely to determine the cause of
remote:  !     the problem, ensure the code you're pushing is functioning
remote:  !     properly, and that all local changes are committed correctly.
remote:  !
remote:  !     For more information on builds for PHP on Heroku, refer to
remote:  !     https://devcenter.heroku.com/articles/php-support
remote:
remote:  !     Push rejected, failed to compile PHP app.

我已经尝试了 Heroku 文档中建议的所有方法来增加内存限制 https://devcenter.heroku.com/articles/php-concurrency#tuning-concurrency-using-memory_limit

但是建议的方法都没有改变内存限制,它保持在 128M,见错误:Allowed memory size of 134217728 bytes exhausted

  • 将内容为 memory_limit = 256M 的 user.init 定位在根文档中。就我而言 /public

  • 将 fpm_costum.conf 与内容 php_value[memory_limit] = 256M 放在根文档和顶级文件夹中,将 Procfile 更改为: web: heroku-php-apache2 /public -F fpm_custom.conf

我没有想法......

【问题讨论】:

    标签: php symfony heroku sylius


    【解决方案1】:

    发生这种情况是因为您的限制没有传播到作为 post 脚本执行的 cache:clear 脚本。尝试改用 COMPOSER_MEMORY_LIMIT 环境变量:

    COMPOSER_MEMORY_LIMIT=512M composer install …
    

    确保您没有覆盖 public/index.php 文件中的此限制。这是我前段时间犯的错误……

    请注意,如果添加更多软件包,很快您将不得不将此值增加到一个 gig。 Sylius 会占用大量内存。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-25
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 2019-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多