I find mancini0's answer over at https://stackoverflow.com/a/63309367/527489 to be more helpful:
some examples for your .bazelrc
build --local_ram_resources=HOST_RAM*.5 --local_cpu_resources=HOST_CPUS-1 (leave one core free)
or
build --local_cpu_resources=1 (use a single core)
See https://docs.bazel.build/versions/master/command-line-reference.html#flag--local_cpu_resources
The currently accepted answer [to Is there a way to limit the number of CPU cores Bazel uses?] is deprecated.
Note that instead of configuring your user.bazelrc
or ~/.bazelrc
, you can instead just pass these on the command line, such as:
bazel build --local_cpu_resources=1 -c opt //npsw/...
bazel test --local_cpu_resources=1 -c opt //npsw/...