Out of memory error in composer when requiring drupal/bootstrap
This is related to your php.ini file's memory_limit entry which defaults to 128M. You need access to your server's php configuration file. If you do here is the step by step for making that change on an Ubuntu server with PHP 7 and PHP CLI extension.


Open the PHP CLI configuration file located at /etc/php/7.0/cli; e.g. I use vim as follows sudo vim /etc/php/7.0/cli/php.ini
Search for the line containing memory_limit by pressing the / (forward slash) key, type the phrase memory_limit and press enter.
Once on that line go to vim's insert mode by pressing 'ESC' followed by 'i'. 
Change the value for the memory_limit to something higher, e.g. memory_limit = 1024M since you already have 512M for the limit.
Save and exit the configuration file by pressing 'ESC' type in 'wq' and then press 'enter'.


If you don't see any changes it could be that you have an error in you php.ini configuration file. You are always welcome to comment on the answers to get more help.