What is the best garbage collector to use for Maven, with a large project
that can ensure no OOM?
I'm looking for reliability over speed.

For the past year or two my machine has locked up in a build
intermittently, requiring a power cycle. I was sure it was a hardware issue
until I bought another machine and the same thing happened.
So I doubled the memory. It was much better, but still problems.
When it started to stutter it got a SIGKILL, but the new machine never
froze up completely.
I didnt think software could bring the machine to its knees, but clearly it
can and I need to make sure Maven doesn't do this.

I was playing with jconsole and found that heap requirements just kept
going up (to around 6Gb for my build without tests). I had to manually
force a GC to release some memory.
The default GC interval in JDK6 was 60 secs. I believe with JDK11 its 60
min, so no full GC in a build.
None of the GCs I looked at allow configuring the interval (unless using
RMI apparently?)

I changed the GC to Shenandoah since it seems to have some intelligence
around when an OOM might occur.
Can someone please comment on my jvm.config?

-enableassertions
-Djava.awt.headless=true
-Xlog:all=warning:stdout:uptime,tags
-XX:TieredStopAtLevel=1
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./mvn_java_heapdump.hprof
-XX:+UseShenandoahGC
-XX:ShenandoahGCHeuristics=compact
-XX:+UseStringDeduplication
-XX:+UseCodeCacheFlushing
-XX:InitialCodeCacheSize=128m
-XX:ReservedCodeCacheSize=256m
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

Here is my prof script someone might find it useful

#!/bin/sh -m
"$@" & sh -c 'jconsole -interval=1 "$@" &' _ "$!"; fg

Then invoke a build with
./prof mvn verify

Kind regards,
Delany

Reply via email to