When you execute the setup:di:compile in magento2, you may get the chances to get the following error message from the terminal.
Fatalerror: Allowed memory size of 134217728 bytes exhausted (tried to allocate 86016 bytes) in setup\src\Magento\Di\Code\Reader\FileClassScanner.php on line 81 Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.
Execute command with some additional memory to resolve this issue.
Ex: php -dmemory_limit=5G bin/magento setup:di:compile
Here i have specify 5G of memory additional & then it start works.We can also increase the memory limit from ini file level. But not suggested to maximize the limit from certain limit of memory from the ini file.