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

feat: dynamic ram assignment when over 1GB #4921

Merged
merged 6 commits into from
Nov 2, 2023
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
21 changes: 20 additions & 1 deletion kura/distrib/src/main/resources/common/customize-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,23 @@ if [ ${BOARD} = "generic-device" ]; then
else
echo "python3 not found. snapshot_0.xml, and iptables.init files may have wrong interface names. Default is eth0 and wlan0. Please correct them manually if they mismatch."
fi
fi

# dynamic RAM assignment
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}')
RAM_MB=$(expr $RAM_KB / 1024)
RAM_MB_FOR_KURA=$(expr $RAM_MB / 4)

if [ "$RAM_MB" -lt 1024 ]; then
RAM_REPLACEMENT_STRING="-Xms256m -Xmx256m"
fi

echo "Setting kura RAM to ${RAM_REPLACEMENT_STRING}"
start_scripts_to_change=("start_kura.sh" "start_kura_debug.sh" "start_kura_background.sh")

RAM_REPLACEMENT_STRING="-Xms${RAM_MB_FOR_KURA}m -Xmx${RAM_MB_FOR_KURA}m"
for installer_name in "${start_scripts_to_change[@]}"; do
echo "Updating RAM values for $installer_name"
sed -i "s/-Xms[0-9]*m -Xmx[0-9]*m/$RAM_REPLACEMENT_STRING/g" "/opt/eclipse/kura/bin/$installer_name"
done

fi