"virtual memory exhausted" while building on RPI

Problems building or running the engine, queries about how to use features etc.
Post Reply
AEtherScythe
Gnoblar
Posts: 4
Joined: Sat Apr 27, 2019 8:10 pm

"virtual memory exhausted" while building on RPI

Post by AEtherScythe » Sat Apr 27, 2019 8:23 pm

Ogre Version: v1.11.5
Operating System: Raspian 9 (stretch)
Render System:

My Raspberry Pi 3 B+ has 1 GB of RAM.
I have added an 8 GB swap file to cope with large builds like OpenCV and Ogre, and that was enough for OpenCV, but not Ogre.
I just added another 2 GB of swap, hoping it's enough.

Since it takes a long time to reach the "virtual memory exhausted" error, and because I'm running low on disk-space, I thought I'd post here to see if anyone has a rough gauge on how much virtual memory is likely needed to complete the build?

(If it's much more than the 1 GB + 10 GB swap I have now, I'll have to move to a larger SD card).

Thanks in advance for any insights! =D
0 x

paroj
OGRE Team Member
OGRE Team Member
Posts: 774
Joined: Sun Mar 30, 2014 2:51 pm
x 120
Contact:

Re: "virtual memory exhausted" while building on RPI

Post by paroj » Sat Apr 27, 2019 8:59 pm

personally I would cross-compile it from an x86 machine. However you can also reduce the number of build jobs to 1 to reduce memory pressure.

"make -j1" or "ninja -j1"
0 x

AEtherScythe
Gnoblar
Posts: 4
Joined: Sat Apr 27, 2019 8:10 pm

Re: "virtual memory exhausted" while building on RPI

Post by AEtherScythe » Sat Apr 27, 2019 9:03 pm

Paroj,
Thanks for the advice. I'll try limiting the jobs.
0 x

AEtherScythe
Gnoblar
Posts: 4
Joined: Sat Apr 27, 2019 8:10 pm

Re: "virtual memory exhausted" while building on RPI

Post by AEtherScythe » Sat Apr 27, 2019 9:07 pm

BTW, I happened to be watching closely when it failed this time (I have not tried limiting the jobs yet).
It turns out it stopped after the cc1plus process tried to exceed 2 GB of virtual memory.
This is a 32-bit platform. I would have expected the limit to be 4 GB.
But anyway, no amount of additional swap is going help this problem, so fingers crossed that limiting the jobs does the trick. =D
0 x

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 3960
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 175
Contact:

Re: "virtual memory exhausted" while building on RPI

Post by dark_sylinc » Sat Apr 27, 2019 11:03 pm

As you noticed, 2GB is the virtual address limit per process and now swapping is going to help you. This is because the other 2GB is reserved for system kernel ranges including device drivers and special addresses (e.g. 0x00000000, 0xCDCDCDCD, etc)

Things that may help:
  • What paroj already suggested
  • Building using OGRE_UNITY_BUILD (if it's still there in Ogre 1.x) and playing with the OGRE_UNITY_FILES_PER_UNIT setting
  • Disabling precompiled headers if they're enabled
  • Trying a different compiler (GCC vs Clang). If you're on a Debian-based distro, "update-alternatives --config c++ " may come handy
  • Disabling optimizations, disabling debug information (i.e. no "-g" option)
  • Trying a different linker (regular ld vs gold)
Use ninja -v / make VERBOSE=1 to see the actual compiler invocation with all of its params.
0 x

AEtherScythe
Gnoblar
Posts: 4
Joined: Sat Apr 27, 2019 8:10 pm

Re: "virtual memory exhausted" while building on RPI

Post by AEtherScythe » Sun Apr 28, 2019 6:37 pm

Thanks for all the advice, folks.
I never did get the build to complete using the defaults even with -j1.
It was dying late in to a part of the build dealing with python bindings.
I don't expect to need those features, so I just disabled them in the cmake input, a la:

-D OGRE_BUILD_COMPONENT_PYTHON=OFF
0 x

Post Reply