I have some JMH benchmarks that I'm trying to analyze. I want to enable GC logging to see how much garbage is being generated, but I can't figure out how to pass JVM arguments. I know JMH runs benchmarks in a forked JVM, so it's not immediately obvious to me how to do this. I'm using SBT.
相关问题
- JVM abnormal exit - cleanup of system resources
- Could not import the newly generated play framewor
- Sanity check: Rhino does not have a require functi
- JVM crashes with problematic frame [libjvm.so+0x7f
- JVM issues with a large in-memory object
相关文章
- java项目突然挂掉,日志无报错信息
- Java引用分为强引用、软引用、弱引用、虚引用,我怎么能判断出一个对象是哪个引用?
- How do you run cucumber with Scala 2.11 and sbt 0.
- java.lang.VerifyError: Stack map does not match th
- Setting up multiple test folders in a SBT project
- Do errors thrown within UncaughtExceptionHandler g
- Run project with java options via sbt
- Build maven project as a part of SBT build
If I read sbt-jmh docs right, it passes the application options to JMH runner with
jmh:run ...
. So, having that JMH command line accepts--jvmArgs "..."
, I would try to dojmh:run --jvmArgs "-XX:+PrintGCDetails"
. Or, as @apangin mentions, add@Fork(jvmArgsAppend = "-XX:+PrintGCDetails")
.But for your particular use case -- "see how much garbage is generated" -- it might be even better idea to use a bundled GC profiler, activated with
-prof gc
. See the example at JMHSample_35_Profilers.java#l71.Use
@Fork
annotation:Note that JVM arguments passed to JMH are also propagated to forked benchmarks.