File tree Expand file tree Collapse file tree 1 file changed +24
-5
lines changed
.github/actions/gradle-args Expand file tree Collapse file tree 1 file changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -21,25 +21,44 @@ runs:
21
21
run : |
22
22
runnerOS=$RUNNER_OS
23
23
24
- # Set common JVM arguments
25
- jvmArgs="-XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
24
+ totalMemory=0
25
+ # How much memory does the OS require?
26
+ memoryOverhead=0
26
27
27
28
case $runnerOS in
28
29
macOS)
29
- jvmArgs="-Xmx10g -XX:MaxMetaspaceSize=5g $jvmArgs"
30
+ totalMemory=$(sysctl -n hw.memsize | awk '{print int($1/1024/1024/1024+0.5)}')
31
+ memoryOverhead=3
30
32
;;
31
33
Linux)
32
- jvmArgs="-Xmx4g -XX:MaxMetaspaceSize=3g $jvmArgs"
34
+ totalMemory=$(awk '/MemTotal/ {print int($2/1024/1024+0.5)}' /proc/meminfo)
35
+ memoryOverhead=3
33
36
;;
34
37
Windows)
35
- jvmArgs="-Xmx3g -XX:MaxMetaspaceSize=756m $jvmArgs"
38
+ # Fetch and parse memory in MB, then convert to GB
39
+ totalMemory=$(powershell -Command "& { [Math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory / 1GB) }")
40
+
41
+ # Check if totalMemory is a valid number
42
+ if ! [[ "$totalMemory" =~ ^[0-9]+$ ]]; then
43
+ echo "Failed to retrieve or parse total memory: $totalMemory"
44
+ exit 1
45
+ fi
46
+ memoryOverhead=3
36
47
;;
37
48
*)
38
49
echo "Unsupported runner OS: $runnerOS"
39
50
exit 1
40
51
;;
41
52
esac
42
53
54
+ availableMemory=$((totalMemory - memoryOverhead))
55
+
56
+ echo " total memory: $totalMemory"
57
+ echo " memory overhead: $memoryOverhead"
58
+ echo "available memory: $availableMemory"
59
+
60
+ jvmArgs="-Xmx${availableMemory}g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8"
61
+
43
62
propertyArgs="-Dorg.gradle.daemon=false -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false"
44
63
45
64
echo "gradle-property-args=$propertyArgs" >> $GITHUB_OUTPUT
You can’t perform that action at this time.
0 commit comments