Leave the Max-Heap-Size to 8Gb, we assume that enough swap space will be available on the host.

We can still override the max-heap-size if desired.
This commit is contained in:
Lampros Smyrnaios 2023-04-29 17:55:03 +03:00
parent d5a997ad3d
commit 0ea7bccadb
3 changed files with 12 additions and 9 deletions

View File

@ -3,8 +3,8 @@
# Info found in: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-20-04
# Creating a Swap File with 2 Gb
sudo fallocate -l 2G /swapfile
# Creating a Swap File with 6 Gb
sudo fallocate -l 6G /swapfile
ls -lh /swapfile
# Enabling the Swap File

View File

@ -24,6 +24,8 @@ fi
gradleVersion="8.1.1"
shouldBeCarefulWithMaxHeap=0 # This is NOT a cmd-arg.
if [[ justRun -eq 0 ]]; then
if [[ avoidReInstallingPublicationsRetriever -eq 1 ]]; then
@ -69,12 +71,14 @@ if [[ justRun -eq 0 ]]; then
export PATH=/opt/gradle/gradle-${gradleVersion}/bin:$PATH
# Update the max-heap-size based on the machine's physical memory.
machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB.
max_heap_size_mb=$(echo "($machine_memory_mb - 800)/1" | bc) # Leave 800 MB to the system (the "()/1" is used to take the floor value).
# Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m"
echo -e "\n\nThe max-heap-size (-Xmx) will be set to: ${max_heap_size_mb}m\n\n"
sed -i "s/'-Xmx[0-9]\+[gm]'/'-Xmx${max_heap_size_mb}m'/g" ./build.gradle
if [[ shouldBeCarefulWithMaxHeap -eq 1 ]]; then
# Update the max-heap-size based on the machine's physical memory.
machine_memory_mb=$(grep MemTotal /proc/meminfo | awk '{print $2}' | xargs -I {} echo "scale=4; {}/1024" | bc) # It returns the size in MB.
max_heap_size_mb=$(echo "($machine_memory_mb - 800)/1" | bc) # Leave 800 MB to the system (the "()/1" is used to take the floor value).
# Now, we replace the "-Xmx" parameter inside the "./build.gradle" file, with "-Xmx${max_heap_size}m"
echo -e "\n\nThe max-heap-size (-Xmx) will be set to: ${max_heap_size_mb}m\n\n"
sed -i "s/'-Xmx[0-9]\+[gm]'/'-Xmx${max_heap_size_mb}m'/g" ./build.gradle
fi
gradle wrapper --gradle-version=${gradleVersion} --distribution-type=bin

View File

@ -55,7 +55,6 @@ public class GeneralController {
shouldShutdownWorker = true;
finalMsg += " The worker will shutdown, after finishing current work.";
logger.info(initMsg + finalMsg);
return ResponseEntity.ok().body(finalMsg + "\n");
}