I have this problem when creating a Composer project in PhpStorm which I use to fetch my pimcore packages.
In pimcore install docs it's explicitly stated that you need to crank up the memory limit to 3Gigs otherwise composer would run out of memory. This can be done by prefixing composer create-project command, it looks like this:
COMPOSER_MEMORY_LIMIT=3G composer create-project pimcore/skeleton my-project
In Phpstorm however I don't know how to append this command COMPOSER_MEMORY_LIMIT=3G when creating the project, and thus composer always runs out of memory.