Stack installation failed on afw-13.0 -- OOM

I’m following the standard instructions to install the stack on an Ubuntu 16.04 machine with 8GB of RAM, but the installation fails on afw-13.0.

[ 56/93 ]  afw 13.0 ... 

***** error: from /home/mdon849/LSST/EupsBuildDir/Linux64/afw-13.0/build.log:
           ^
In file included from /home/mdon849/LSST/Linux64/eigen/3.2.5.lsst2/include/Eigen/Core:276:0,
                 from include/lsst/afw/geom/CoordinateBase.h:36,
                 from include/lsst/afw/geom.h:32,
                 from include/lsst/afw/image.h:30,
                 from python/lsst/afw/math/mathLib_wrap.cc:3721:
/home/mdon849/LSST/Linux64/eigen/3.2.5.lsst2/include/Eigen/src/Core/Functors.h:977:28: warning: 'template<class _Operation> class std::binder1st' is deprecated [-Wdeprecated-declarations]
 struct functor_traits<std::binder1st<T> >
                            ^
In file included from /usr/include/c++/5/bits/stl_function.h:1128:0,
                 from /usr/include/c++/5/string:48,
                 from /usr/include/c++/5/stdexcept:39,
                 from python/lsst/afw/math/mathLib_wrap.cc:3645:
/usr/include/c++/5/backward/binders.h:108:11: note: declared here
     class binder1st
           ^
virtual memory exhausted: Cannot allocate memory
scons: *** [python/lsst/afw/math/mathLib_wrap.os] Error 1
scons: building terminated because of errors.
+ exit -4
eups distrib: Failed to build afw-13.0.eupspkg: Command:
	source /home/mdon849/LSST/eups/bin/setups.sh; export EUPS_PATH=/home/mdon849/LSST; (/home/mdon849/LSST/EupsBuildDir/Linux64/afw-13.0/build.sh) >> /home/mdon849/LSST/EupsBuildDir/Linux64/afw-13.0/build.log 2>&1 4>/home/mdon849/LSST/EupsBuildDir/Linux64/afw-13.0/build.msg 
exited with code 252

I’ve read the discussion on this thread, and tried running without debug symbols using SCONSFLAGS='debug=0' – however, this gets overwritten by eups.

Could someone please clarify whether turning off debug symbols will work, and if so, what value EUPSPKG_SCONSFLAGS should be set to? It was somewhat unclear from this comment.

The import value is -j 1 to limit the amount of concurrent processes, specifically during linking. We have been unable to use VMs for building with less than 16GiB of RAM, unless the build is restricted to 1-2 cores.

If you are doing an EUPS distrib install you can probably get the desired result by setting NJOBS=1.