Zend certified PHP/Magento developer

magento command failing, getting “killed”

am using these commands but keep getting this at the end that it got killed

php -d memory_limit=2G bin/magento setup:static-content:deploy
php -d memory_limit=2G bin/magento setup:di:compile

is 4G memory not enough? how can i know how much memory is really needed?
it shows compilation is started but then i get something like this 254MibKilled