How to disable the memory limit for a Magento 2 console command?

Use the -d command line option:

php -d memory_limit=-1 <your command>

Example:

php -d memory_limit=-1 bin/magento setup:upgrade

Details:

-d --define
Set a custom value for any of the configuration directives allowed in php.ini.

http://php.net/manual/en/features.commandline.options.php