From abfb5b7720624eeec1ed3fc402833b042b690185 Mon Sep 17 00:00:00 2001 From: Botspot Date: Wed, 8 Sep 2021 23:17:58 -0500 Subject: [PATCH] Box64: use fewer threads for low-ram devices --- apps/Box64/install-64 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/Box64/install-64 b/apps/Box64/install-64 index 9295553..944a76e 100755 --- a/apps/Box64/install-64 +++ b/apps/Box64/install-64 @@ -13,7 +13,17 @@ rm -rf ~/box64 git clone https://github.com/ptitSeb/box64 || error 'Failed to clone box64 repository!' cd box64 || error 'Failed to change directory' mkdir build; cd build; cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo || error 'Failed to run cmake in "build" directory' -make -j8 || error 'Failed to compile' + +#determine how many threads can run without running out of memory +if [ $(($(free -bt | tail -1 | awk '{print $2}')-$(free -bt | tail -1 | awk '{print $3}'))) -le 2000000000 ];then + #less than 2GB of available ram + threads=3 +else + #greater than 2GB of available ram + threads=5 +fi +echo "Compiling Box64 with $threads threads..." +make -j${threads} || error 'Failed to compile' sudo make install || error 'Failed to run "sudo make install"' if ! sudo systemctl restart systemd-binfmt ;then