Suppose you have a small amount of RAM & the site is running on Magento 2.
It’s will not create any problem if the cache is enabled, but create a problem when compile, as compilation takes huge memory and storage,
So first check the RAM space by
it will show memory used & available by Megabyte unit,
if at least 500 MB memory free you can use
php bin/magento setup:di:compile
command to compile, if not then you have to use.
php -d momory_limit=-1 magento setup:di:compile
It’s will help to take unlimited RAM, if RAM not available then from disk space.
If this command not working then you may have a serious amount of small ram or your disk space is not enough.
to check disk space
and if memory is full then free up some space.