Jaglover is right.
In order to compile Virtualbox (and 1 or 2 other packages),
I do a fresh reboot, disable GDM, and do not let the DE load up.
I then run the emerge from tty1.
I usually do this overnight.
By doing this, I am freeing up as much RAM as possible and therefore making it available to the compiler.
Virtualbox needs lots of RAM to build.
It's usually done by the morning._________________Whatever you do, do it properly!