Member-only story
We had a big multi module polyglot project consisting of scala and java code. On top of the regular source , we also added more test cases , subsequently this increased the build time and we we started noticing build time out of memory errors.
Initially, we suspected it might the app and tests itself that has some memory leak that was causing the build to fail but we soon discovered that wasn’t the case.
The first step I did was to connect the build process to a jvm profiler. I used the default profiler that comes with jdk itself , `jvisualvm`. This one is pretty handy to quickly diagnose any memory or thread issue
Check if there is `jvisualvm` on your path
$ whereis jvisualvm
/usr/bin/jvisualvm
Now start your build process, that eventually fails
$ ps -ef | grep maven
This should list all your process that has maven keyword, make sure you pick the note the correct PID. In my case, above command returned my process that was launched for maven build
501 20593 5121 0 2:12PM ttys001 38:22.96 ~/.jenv/versions/1.8.0.131/bin/java -Xms768M -Xmx1536M -XX:MetaspaceSize=256M -XX:MaxMetaspaceSize=3584M -XX:InitialBootClassLoaderMetaspaceSize=32M -XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=96M -classpath /usr/local/Cellar/maven@3.5/3.5.4_1/libexec/boot/plexus-classworlds-2.5.2.jar…