From 7af21dd996049fc4289595adbfd119217cd78e4e Mon Sep 17 00:00:00 2001 From: Jeffrey E Erickson Date: Mon, 3 Feb 2025 09:35:02 -0600 Subject: [PATCH] modify max memory to use free (#1513) --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38f0848157..7be6c5c590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -836,10 +836,11 @@ if (${memory_max_string} MATCHES "^[0-9]+") math(EXPR memory_in_gb "${memory_max_string} / (1024 * 1024 * 1024)") else() execute_process( - COMMAND bash "-c" "cat /sys/fs/cgroup/memory/memory.limit_in_bytes" + COMMAND bash "-c" "free | grep -o '[[:digit:]]*' | head -1" OUTPUT_VARIABLE memory_max_string) + ## memory_max_string holds the free memory in KB if (${memory_max_string} MATCHES "^[0-9]+") - math(EXPR memory_in_gb "${memory_max_string} / (1024 * 1024 * 1024)") + math(EXPR memory_in_gb "${memory_max_string} / (1024 * 1024)") ## KB to GB conversion else() cmake_host_system_information(RESULT memory_max_string QUERY AVAILABLE_PHYSICAL_MEMORY ) math(EXPR memory_in_gb "${memory_max_string} / 1024")