8

While looking at possible JVM flags for optimizing launching startup time of my RCP product, I found these attractively-named -XX:UseFastEmptyMethods and -XX:UseFastAccessorMethods.

It seems that those flags were available on JDK-6 (and on by default), while they were defaulted to off on JDK-7. Also, I read that the trade-off for this optimization is that they do not increase method invocation counters.

What is the impact of not using invocation counters? Does that affect garbage collection?

4

1 回答 1

9

这是为了正确获取方法的调用计数,以便 VM 可以更好地识别代码中的热点。

这里开始讨论

如果您使用的是 JDK6,则可能需要在目标 Java 应用程序中包含这两个 VM 标志:
-XX:-UseFastEmptyMethods -XX:-UseFastAccessorMethods

否则方法和访问器方法将不会显示在列表中,因为“快速”版本不会增加这些方法的调用计数器。在 JDK7 中,这两个标志默认为 false,因此您不必费心将它们显式设置为 false。


也可以看看 :

UseFastEmptyMethods/UseFastAccessorMethods 被认为是有害的

于 2013-03-14T05:01:55.317 回答