Note that the swap file is not automatically invoked at the next start-up. For permanently invoking the swap file add to /etc/fstab
/var/lib/swap/swapfile swap swap defaults 0 0
On my system, this prolonged, however, start-up time considerably. Depending on your system, try the above procedure with smaller sizes of swap files first and increase it step by step until compilation works.