Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openjdk.mk: make MEMORY_SIZE computation portable #5350

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openjdk/openjdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ ifeq ($(OS),Linux)
#
# // If this machine/container uses cgroups to limit the amount of
# // memory available to us, we should use that as out memory size.
# if [[ -r /sys/fs/cgroup/memory.max ]]; then
# if [ -r /sys/fs/cgroup/memory.max ]; then
# // Use this to identify memory maximum (bytes) for cgroup v2.
# CGMEM=`cat /sys/fs/cgroup/memory.max 2>1`;
# else
Expand All @@ -37,7 +37,7 @@ ifeq ($(OS),Linux)
#
# // If those files were empty, or didn't exist, or had non-numbers
# // in them, then use /proc/meminfo (converted to bytes).
# if [[ ! $$(CGMEM) =~ ^[0-9]+$$ ]]; then
# if echo "$${CGMEM}" | grep -Eqv '^[0-9]+$$' ; then
# CGMEM=`expr $${KMEMMB} \* 1024 \* 1024`;
# fi;
#
Expand All @@ -50,7 +50,7 @@ ifeq ($(OS),Linux)
# if [ "$${KMEMMB}" -lt "$${CGMEMMB}" ]; then
# echo "$${KMEMMB}"; else echo "$${CGMEMMB}";
# fi
MEMORY_SIZE:=$(shell KMEMMB=`awk '/^MemTotal:/{print int($$2/1024)}' /proc/meminfo`; if [[ -r /sys/fs/cgroup/memory.max ]]; then CGMEM=`cat /sys/fs/cgroup/memory.max 2>1`; else CGMEM=`cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>1`; fi; if [[ ! $${CGMEM} =~ ^[0-9]+$$ ]]; then CGMEM=`expr $${KMEMMB} \* 1024 \* 1024`; fi; CGMEMMB=`expr $${CGMEM} / 1024 / 1024`; if [ "$${KMEMMB}" -lt "$${CGMEMMB}" ]; then echo "$${KMEMMB}"; else echo "$${CGMEMMB}"; fi)
MEMORY_SIZE:=$(shell KMEMMB=`awk '/^MemTotal:/{print int($$2/1024)}' /proc/meminfo`; if [ -r /sys/fs/cgroup/memory.max ]; then CGMEM=`cat /sys/fs/cgroup/memory.max 2>1`; else CGMEM=`cat /sys/fs/cgroup/memory/memory.limit_in_bytes 2>1`; fi; if echo "$${CGMEM}" | grep -Eqv '^[0-9]+$$' ; then CGMEM=`expr $${KMEMMB} \* 1024 \* 1024`; fi; CGMEMMB=`expr $${CGMEM} / 1024 / 1024`; if [ "$${KMEMMB}" -lt "$${CGMEMMB}" ]; then echo "$${KMEMMB}"; else echo "$${CGMEMMB}"; fi)
endif
ifeq ($(OS),Darwin)
NPROCS:=$(shell sysctl -n hw.ncpu)
Expand Down