OpenCV install failed ... because I'm out of memory?

I’d suggest to disable precompiled headers for building. You may use :

Note that it may took a huge disk space depending on the options that you’ve enabled at configure time such as tests, perftests, non-free, …).