Hello, I have 16gb of ram and around 32gb of swap. This doesnt happen on any other distro.
You can try stopping systemd-oomd before starting your build:
sudo systemctl stop systemd-oomd.service
i have done that once building android from source and it is hard but best to use ubuntu it is highly compatible