EC2のコンテナ上で展開しているPHPの環境があり、composerで構成しています。
composerを実行したところ、メモリ不足で実行できませんでした。
Loading composer repositories with package information Updating dependencies (including require-dev) mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory Fatal error: Out of memory (allocated 386723840) (tried to allocate 9210786 bytes) in phar:///usr/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 459
メモリの上限をあげる方法を色々試してみたのですが、解決できず何か他に変更する方法はないでしょうか?
サーバーの性能について
EC2のt2.microインスタンスを使っていますので、メモリは1GBです。
実際に使用できるメモリ容量は約1GB弱なので、容量が不足している可能性はないと思われます。
sh
1$ docker stats (dockerコンテナ)
MEM USAGE | LIMIT |
---|---|
8.277MiB | 983.7MiB |
試した事
php.iniファイルの上限をあげる
phpの設定で上限を変えるために、docker-compose up
時に追加するiniファイルにmemory_limit = 512M
にして立ち上げました。
ini
1[php] 2memory_limit = 512M
しかし、tried to allocate
上限は変わりません。
実際にコンテナにexecで入り、phpinfo()
から直接確認しましたが、設定自体は変わっている事を確認しました。
sh
1$ php -r 'phpinfo();' | grep memory_limit 2memory_limit => 512M => 512M
コマンドラインで実行した時だけ、メモリの制限上限を
phpとcomposerそれぞれのメモリリミットを変更して見ましたが、メモリが変わりません。
phpのリミットを変更
上限を解除するために、memory_limit
オプションを追加した状態でビルドしてみました。
sh
1$ php -d memory_limit=-1 /usr/bin/composer install
composerのリミット変更
上限を解除するために、COMPOSER_MEMORY_LIMIT
オプションを追加した状態でビルドしてみました。
sh
1$ COMPOSER_MEMORY_LIMIT=-1 composer install
composer時のログ
リミット変更時に、変更があるかもしれないと思いcomposer install -vvv
で見てみましたが、知識不足で原因を見つけることができませんでした。
sh
1$ php -d memory_limit=-1 /usr/bin/composer install -vvv 2Reading ./composer.json 3Loading config file ./composer.json 4Checked CA file /etc/ssl/certs/ca-certificates.crt: valid 5Executing command (/var/www): git branch --no-color --no-abbrev -v 6Executing command (/var/www): git describe --exact-match --tags 7Executing command (/var/www): git log --pretty="%H" -n1 HEAD 8Executing command (/var/www): hg branch 9Executing command (/var/www): fossil branch list 10Executing command (/var/www): fossil tag list 11Executing command (/var/www): svn info --xml 12Failed to initialize global composer: Composer could not find the config file: /root/.composer/composer.json 13To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section 14Running 1.8.6 (2019-06-11 15:03:05) with PHP 7.2.19 on Linux / 4.14.121-109.96.amzn2.x86_64 15Loading composer repositories with package information 16Downloading https://repo.packagist.org/packages.json 17Writing /root/.composer/cache/repo/https---repo.packagist.org/packages.json into cache 18Updating dependencies (including require-dev) 19Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2013.json from cache 20Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2014.json from cache 21Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2015.json from cache 22Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2016.json from cache 23Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2017.json from cache 24Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2018.json from cache 25Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2018-10.json from cache 26Downloading http://repo.packagist.org/p/provider-2019-01%243295bb914c7815748ee210203dca40edbf9bf1fa1e8bfa4788919c646f9cb2be.json 27Writing /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2019-01.json into cache 28Downloading http://repo.packagist.org/p/provider-2019-04%2476814d375d8b753fc8a655956f4804ada8be962cebbbf8b665f5c4b7eb3e1a01.json 29Writing /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2019-04.json into cache 30Downloading http://repo.packagist.org/p/provider-2019-07%24ce294b73ec16ae3655063841b37f82028db8da0f2d3d05069bc09e9d6d6b3a37.json 31Writing /root/.composer/cache/repo/https---repo.packagist.org/p-provider-2019-07.json into cache 32Reading /root/.composer/cache/repo/https---repo.packagist.org/p-provider-archived.json from cache 33Downloading http://repo.packagist.org/p/provider-latest%24788a051f4a9cd5933b41c98ae8788cf0613bd0b6b85f04df6170a65ee3261422.json 34Writing /root/.composer/cache/repo/https---repo.packagist.org/p-provider-latest.json into cache 35Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-laravel$laravel.json from cache 36Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-endroid$qr-code.json from cache 37Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-bacon$bacon-qr-code.json from cache 38Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-endroid$installer.json from cache 39Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-khanamiryan$qrcode-detector-decoder.json from cache 40Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-myclabs$php-enum.json from cache 41Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$http-foundation.json from cache 42Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$options-resolver.json from cache 43Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$property-access.json from cache 44Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-dasprid$enum.json from cache 45Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-mbstring.json from cache 46Downloading http://repo.packagist.org/p/symfony/polyfill-php70%24206ebeb77d2e1d7d9466f2ac634b5f2f94523b17acc3b5cb22f194a0b5764259.json 47Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-php70.json into cache 48Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$mime.json from cache 49Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$inflector.json from cache 50Downloading http://repo.packagist.org/p/paragonie/random_compat%24ae8b0d2677b2b015ef3fcb7a1680c724e7c51d7bcc76c2ecd8405fb0ff597e92.json 51Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-paragonie$random-compat.json into cache 52Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-intl-idn.json from cache 53Downloading http://repo.packagist.org/p/symfony/polyfill-ctype%24f425dfc720a65a43b3815a48923ca568d1a9db63dfc6072224dab3a08b7382fe.json 54Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-ctype.json into cache 55Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$polyfill-php72.json from cache 56Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-fideloper$proxy.json from cache 57Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$contracts.json from cache 58Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-psr$container.json from cache 59Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-psr$simple-cache.json from cache 60Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-guzzlehttp$guzzle.json from cache 61Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-guzzlehttp$psr7.json from cache 62Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-guzzlehttp$promises.json from cache 63Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-psr$http-message.json from cache 64Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-ralouphie$getallheaders.json from cache 65Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-kris$laravel-form-builder.json from cache 66Downloading http://repo.packagist.org/p/laravelcollective/html%24e21fab862745fb1b95dd8f0814b8ff144ff12101517540d13c9c5198991c7dd1.json 67Writing /root/.composer/cache/repo/https---repo.packagist.org/provider-laravelcollective$html.json into cache 68Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$database.json from cache 69Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$validation.json from cache 70Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$http.json from cache 71Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$routing.json from cache 72Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$session.json from cache 73Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$support.json from cache 74Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$view.json from cache 75Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$container.json from cache 76Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-nesbot$carbon.json from cache 77Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$translation.json from cache 78Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-illuminate$translation.json from cache 79Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-egulias$email-validator.json from cache 80Reading /root/.composer/cache/repo/https---repo.packagist.org/provider-symfony$http-kernel.json from cache 81Downloading http://repo.packagist.org/p/illuminate/pipeline%24f4a2e4383e9a0e0c0e02c0289dbc90405bfbe7a47a58d18c042e266858305c0c.json 82 83mmap() failed: [12] Cannot allocate memory 84 85mmap() failed: [12] Cannot allocate memory 86 87Fatal error: Out of memory (allocated 386723840) (tried to allocate 9210786 bytes) in phar:///usr/bin/composer.phar/src/Composer/Util/RemoteFilesystem.php on line 459

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/07/24 07:51 編集
2019/07/24 07:51
2019/07/24 07:58