If you want to minimimze the memory overhead of the running JVM, as well as make it so the consumed heap size stays as close to the actual ammount of consumed heap from your app, I've found running with the following args to work best:
clojure -J-XX:+UseSerialGC -J-Xmx256m -J-Xms1m -J-Xss256k -J-XX:MaxHeapFreeRatio=10 -J-XX:MinHeapFreeRatio=1 -J-XX:-ShrinkHeapInSteps -J-X
X:TieredStopAtLevel=1
- SerialGC has the least memory overhead of all GCs, in that it itself doesn't require a lot of memory to run.
- SerialGC is also good at quickly releasing Heap memory back to the OS if you configure it as such.
- TieredStopAtLevel=1 will disable C2 compilation, this used to be called
-client
option in older JDKs, it won't run as fast due to less optimized compilation, but it needs a lot less memory.