Disabling Java GC for benchmarking


Benchmarking anything is hard since you need to isolate to just the code you want to compare.

With Java, one thing that you have to get rid of is garbage collection during the benchmark. Here are the command line parameters to do that:

java \
	-XX:+AlwaysPreTouch \
	-XX:+UnlockExperimentalVMOptions \
	-XX:+UseEpsilonGC \
	-Xms4g \
	-Xmx4g \
	ClassToBenchmark

Date: 2025-06-06

Tags:  java

Share: