maslan maslan - 2 months ago 23
Java Question

JMH add memory using Options builder

I am running a JMH benchmark:

Options opt = new OptionsBuilder()
.output("C:/test/infinispan/benchmarkThr" + THREAD_COUNT + ".txt")
.include(InfinispanFileStoreCreateUpdateGetBenchmark.class.getSimpleName())
.include(InfinispanMemoryCreateUpdateGetBenchmark.class.getSimpleName())
//.jvmArgsPrepend("-Xms1024m -Xmx1024m")
.warmupIterations(0)
.measurementIterations(INTERATIONS)
.timeUnit(TimeUnit.MILLISECONDS)
.mode(Mode.SingleShotTime)
.threads(THREAD_COUNT)
.forks(1)
.build();

new Runner(opt).run();


I get OutOfMemoryError. I wanted to add more (the commented out text) but I iget an error that seems strange to me (this should IMO work):

# Run progress: 0,00% complete, ETA 00:16:40
# Fork: 1 of 1
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Invalid initial heap size: -Xms1024M -Xmx1124M


How to succesfully add the memory?

Answer

Provide each argument separately using 2 String instead of one as next:

...
.jvmArgs("-Xms1024m", "-Xmx1024m")
...
Comments