Composer out of memory errors
When bundles are being built Servd will run composer install to make sure all of your project's packages are ready and waiting for you when you deploy the bundle.
Sometimes composer can experience an out of memory error during this process as the Servd Task Runner limits its maximum memory to 1.5GB.
There are a few things you can do to ensure that this is no longer a problem.
Commit a composer.lock file
You should always commit a composer.lock file.
It not only vastly reduces the amount of memory and time needed to run composer install, it also ensures that the versions of packages installed in your bundle are an exact match against those you were using during local development.
Switch to Composer 2
Composer 2 is available for use on Servd and has a lot of performance improvements built in. Some Craft plugins are not compatible with Composer 2 so we still default to Composer 1, but you can switch between versions on the Project Settings > Build & Deploy page.
Changing this will switch the version of composer used to build your bundles and won't have any impact on previously built or currently deployed bundles.
Include the Servd plugin or yiisoft/yii2-redis in your composer.json
Servd requires a package called yiisoft/yii2-redis to be installed so that we're able to store your cache and session files in Redis. The task runner will check to see if you have already included it in your composer.json and composer.lock files. If it already exists, it doesn't need to do anything else and everyone can get on with their day.
If it doesn't find it, it runs composer require yiisoft/yii2-redis. This kicks off a process which checks all of the versions of yii2-redis against all of the versions for your other dependencies to try to find any conflicts. It is this process which often causes out of memory errors.
The solution is simple though: just composer require yiisoft/yii2-redis during local development which will add yii2-redis to your composer.json and composer.lock files. Once they're in there and committed, Servd will no longer attempt to install the package and your memory errors should vanish!
The Servd Assets and Helpers plugin also includes the yii2-redis package as a dependency so if you have the Servd plugin installed in your project, you already have yii2-redis installed too.