Skip to content

Commit 481aa70

Browse files
authored
Default to 75% ram
1 parent 73f4397 commit 481aa70

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/universalJavaApplicationStub

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,18 @@ if [ $exitcode -eq 0 ]; then
223223
# expand variables $APP_PACKAGE, $APP_ROOT, $JAVAROOT, $USER_HOME (#84)
224224
JVMDefaultOptions=$(eval echo "${JVMDefaultOptions}")
225225

226+
if [[ "$JVMDefaultOptions" != *"-Xmx"* ]]; then
227+
# Ram size in bytes
228+
totalram=$(sysctl -n hw.memsize)
229+
230+
# Ram size in mb
231+
ram_size=$((totalram/1048576))
232+
233+
# Percentage Memory
234+
mem=$(( ram_size*75/100 ))
235+
JVMDefaultOptions+=" -Xmx$((mem))m";
236+
fi
237+
226238
# read StartOnMainThread and add as -XstartOnFirstThread
227239
JVMStartOnMainThread=$(plist_get_java ':StartOnMainThread')
228240
if [ "${JVMStartOnMainThread}" == "true" ]; then

0 commit comments

Comments
 (0)