g++: fatal error: Killed signal terminated program cc1plus compilation terminated.

Hi everyone, I've been having lot of problems trying to install "raster" package, it's seems there's a problem trying to install "terra" package, which seems to be necessary to run the "raster" package, but Rstudio shows me this error:
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make: *** [/opt/R/4.1.2/lib/R/etc/Makeconf:177: RcppModule.o] Error 1
ERROR: compilation failed for package ‘terra’

  • removing ‘/cloud/lib/x86_64-pc-linux-gnu-library/4.1/terra’
    Warning in install.packages :
    installation of package ‘terra’ had non-zero exit status

The downloaded source packages are in
‘/tmp/Rtmp4Gg7QX/downloaded_packages’

I've searched on the internet and saw that it seems to be that i´m running out of memory, but it happens every time i try to start a new project. Its very strange, because on sunday I actually installed this package without any problem. Any help?
Thank you all.