Closed kmecpp closed 5 years ago
I had the same problem, it worked then when I ran gradle with the --no-daemon
flag.
I have the same issue, also under Windows.
I figured out that the cause is in ShutdownTimeoutThread
class in JMH sources.
Basically, it waits for some time after the last benchmark was finished.
According to its javadoc, this should happen in two cases only. I couldn't figure out which one happens here, but it doesn't really matter.
By default, timeout is 30 seconds, and this could be changed with jmh.shutdownTimeout
property.
So, one workaround is to just wait. I tested it with default timeout, after ~30 seconds jar file really becomes unlocked.
Another workaround is to change this property.
Third workaround is to:
forceGC
option to true
Every time I run gradle with
gradle jmh
, the first time it will run successfully and then the next time it will fail with this exceptionHere is my
build.gradle
I realized after a while that the reason why it was failing was because it was unable to overwrite the previous jmh jar file that was created, and the reason for that is that Java processes were still running even after the gradle build finishes.
Each time I run the jmh gradle task, the plugin starts 5 new processes: 3 JVMs and two command lines. I have to restart task manager, delete all the new processes and then I am able to run another gradle build.
Screenshot of after gradle exits, and the processes using the JMH jar are still running