Why Installing Laravel 5.7 on ubuntu I have fork failed - Cannot allocate memory in error

Hello,

Installing Laravel 5.7 app on ubunutu 16 under LEMP/AWS I got error :

# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing symfony/polyfill-ctype (v1.11.0)
    Downloading: 100%         
The following exception is caused by a lack of memory and not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

PHP Fatal error:  Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(ErrorException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application.ph in /usr/share/php/Symfony/Component/Console/Application.php on line 943

Fatal error: Uncaught ErrorException: proc_open(): fork failed - Cannot allocate memory in /usr/share/php/Symfony/Component/Console/Application.php:943
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'proc_open(): fo...', '/usr/share/php/...', 943, Array)
#1 /usr/share/php/Symfony/Component/Console/Application.php(943): proc_open('stty -a | grep ...', Array, NULL, NULL, NULL, Array)
#2 /usr/share/php/Symfony/Component/Console/Application.php(751): Symfony\Component\Console\Application->getSttyColumns()
#3 /usr/share/php/Symfony/Component/Console/Application.php(712): Symfony\Component\Console\Application->getTerminalDimensions()
#4 /usr/share/php/Symfony/Component/Console/Application.php(645): Symfony\Component\Console\Application->getTerminalWidth()
#5 /usr/share/php/Symfony/Component/Console/Application.php(127): Symfony\Component\Console\Application->renderException(Object(ErrorException), Object(Symfony\Component\Console\Output\StreamOutput))
#6 /usr/share/php/Composer/Console/Application.ph in /usr/share/php/Symfony/Component/Console/Application.php on line 943

This project has no big number of installed packages(actually that is laravel / vuejs app),

composer.json of this project: 
{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "fzaninotto/faker": "^1.8",
        "intervention/image": "^2.4",
        "laracasts/utilities": "^3.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "orangehill/iseed": "^2.6",
        "pusher/pusher-php-server": "^3.4",
        "tymon/jwt-auth": "^1.0.0",
        "wboyz/laravel-enum": "^0.2.1",
        "zizaco/entrust": "^1.9"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "beyondcode/laravel-query-detector": "^1.0",
        "filp/whoops": "^2.0",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0",
        "xethron/migrations-generator": "^2.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

Also strange thing that I have installed my applications in ubuntu 18 under Digital Ocean with the same memory quantity.
on AWS Ubuntu 16:

# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 16.04.6 LTS
4.4.0-1084-aws
x86_64


# free
              total        used        free      shared  buff/cache   available
Mem:        1014384       48724      856564         700      109096      824368
Swap:       1048572      264404      784168

on Digital Ocean Ubuntu 18(this app works ok):

# lsb_release -d; uname -r; uname -i
Description:    Ubuntu 18.04.1 LTS
4.15.0-47-generic
x86_64
# free
              total        used        free      shared  buff/cache   available
Mem:        1009156      324640      109012       52520      575504      473160
Swap:       1048572      357888      690684

Can the reason of error on AWS Ubuntu 16 that something is not configured properly?
Though I installed and configured both servers on AWS and Digital Ocean, maybe I missed something on AWS Ubuntu 16 ?

Thanks!

I found this answer on stackoverflow and it says the service provider was limiting the server’s memory. Maybe AWS do this thing too since they both have the same total memory and swap