How should I stop the forked VM?

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Jan 12 09:57:21 UTC 2015


Hi,

On 01/12/2015 12:50 PM, Behrooz Nobakht wrote:
> So I started to use jstack -l on the ForkedMain for my benchmark. Here are
> some observations:
> 
>    - There are threads all with TIMED_WAITING state.
>    - I do not have explicit control over the above threads.
>    - If I do a System.exit(0) somewhere inside ForkedMain, then JMH is
>    annoyed and will not continue.

I smell a bug here, can you produce a minimal scenario?

> Is there a way, I can safely, issue a System.exit() and JMH would continue
> to finalize the benchmark?

Calling System.exit() from the benchmark running in a forked VM should
produce a benchmark failure, while still properly shutting down the
forked VM.

There is no way to call a magic method and have a graceful shutdown. You
have to control the threads. As the minimal option, you have to make the
threads daemon, so that their existence would not prevent forked VM from
exiting.

Thanks,
-Aleksey.



More information about the jmh-dev mailing list