Unable to build from source (Ubuntu)

I have a total of 8GB ram, and 8GB swap space. While building mongo from source, the usage goes out of bounds, and it crashes. As far as i have notices, the swap space goes to a maximum of 1.3G before crashing, I was wondering if this is what is intended by the OS?

PS. It successfully got built in my 8GB RAM intel mac (2017 model)

Hence, I Wanted to confirm if increasing my RAM to 16 or 24GB would actually solve the issue? Like what could the max RAM usage jump to?

Thanks

As per https://jira.mongodb.org/browse/SERVER-68043

Try running using -j1 or -jX (where X is the number of threads). Example:

python3 buildscripts/scons.py install-mongod -j1