Its my first project in magento. I am confuse about deployment and compilation. When i do compilation every time after changes i got some error. Also deployment have many more time memory failed and execution error.
I m using these steps after every changes.
sudo rm -rf var/di var/generation/ var/cache and var/page_cache pub/static/frontend pub/static/_requirejs/ pub/static/adminhtml
sudo chmod -R 777 var pub lib app/etc
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento setup:upgrade
php -dmemory_limit=2G bin/magento indexer:reindex
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento deploy:mode:set production -s
php -dmemory_limit=2G -dmaximum_execution_time=1800 bin/magento setup:di:compile
#php -d allowedmax_execution_time=3000 bin/magento setup:static-content:deploy
php -f bin/magento setup:static-content:deploy
But in deployment and comilation its failed every time due to memeory and execution error.
My question is when compilation and deployment required in magento 2 .