Error about gazebo sitl building

I am using ubuntu18.04 to build the px4’code for gazebo’s sitl. However it encounters error.How to fix it?Thank you!

cc1plus: out of memory allocating 1048576 bytes after a total of 8019968 bytes
[34/86] Building CXX object CMakeFiles/LiftDragPlugin.dir/src/liftdrag_plugin/liftdrag_plugin.cpp.o
[35/86] Building CXX object CMakeFiles/gazebo_motor_model.dir/src/gazebo_motor_model.cpp.o
[36/86] Building CXX object CMakeFiles/gazebo_magnetometer_plugin.dir/src/gazebo_magnetometer_plugin.cpp.o
[37/86] Building CXX object CMakeFiles/gazebo_multirotor_base_plugin.dir/src/gazebo_multirotor_base_plugin.cpp.o
ninja: build stopped: subcommand failed.
ninja: build stopped: subcommand failed.
Makefile:200: recipe for target ‘px4_sitl’ failed
make: *** [px4_sitl] Error 1

Looks like you ran out of memory. Is this in a virtual machine? And if so, could you raise the available RAM?

Thank you for your reply.But I don’t use virtual machine.I run it in ubuntu which is installed directly in my PC.So,how could I fix the problem? thank you!

Ok, in that case try building with less cores:

make px4_sitl gazebo -j1