Alexey, you can check /etc/portage/make.conf and see if there is a MAKEOPTS="-j8" or similar variable. If not, add it and make the number of jobs small, like "-j2". I have a similar problem when I build sys-devel/binutils; it is a huge memory hog.
- Matthew

