Home > Software engineering >  memory_limit problem while running composer install on Symfony gitlab CI
memory_limit problem while running composer install on Symfony gitlab CI

Time:05-16

I'm trying to add Gitlab CI for a Symfony project and on the build stage I have a script that installs required extensions and libraries, at the end, runs composer install:

apt-get update -yqq \
&& apt-get install git libcurl4-gnutls-dev libicu-dev libmcrypt-dev libvpx-dev libjpeg-dev libpng-dev libxpm-dev zlib1g-dev libfreetype6-dev libxml2-dev libexpat1-dev libbz2-dev libgmp3-dev libldap2-dev unixodbc-dev libpq-dev libsqlite3-dev libaspell-dev libsnmp-dev libpcre3-dev libtidy-dev libzip-dev libonig-dev -yqq \
&& docker-php-ext-install mbstring pdo_mysql curl json intl gd xml zip bz2 opcache \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug \
&& curl -sS https://getcomposer.org/installer | php \
&& php composer.phar install

the problem is I get memory_limit error as follows:

!!  
!!  In 40bd61cdac921aa5789618d083759e080acd3c990e06953a3380ae5c5e1156fa.php line 3768:
!!                                                                                 
!!    Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate   
!!    122880 bytes)                                                                
!!                                                                                 
!!  
!!  cache:clear [--no-warmup] [--no-optional-warmers]
!!  
!!  

I tried to increase PHP memory_limit from 128M to 256M but it doesn't work. I tried the following:

php -d memory_limit=256M composer.phar install

I also tried php -r "ini_set('memory_limit', '256M');" but it does not have any effects too.

any suggestions on how to solve this problem?

CodePudding user response:

Do you have the composer.lock in your git repo? install normaly is fast and doesnt need a lot of memory because there is no dependenciy tree generation. if you didnt commit your composer.lock you really should. (this also ensures you use the same versions as you did locally. no strange bugs because of different versions used)

you can also try with:
php -d memory_limit=-1 composer install

CodePudding user response:

How about your docker image? you can try to modify your php.ini in the build docker image. ex. add memory_limit in the docker file.

echo 'memory_limit = 512M' >> /etc/php.d/docker-gitlab-ci-runner-php.ini
  • Related