Penkie But I don't think swap is a good idea.
Any reason why? Swap is advised exactly in these circumstances because it allows scripts like composer to work without memory issues.
An alternative would be restarting your server, and then running the composer create-project command as soon as it's back up and running, but eventually you will encounter a time when composer execution will run out of memory again and be killed.