JVM Compile Time vs Code Cache

Deadly 提交于 2019-12-04 09:46:58

In HotSpot JVM all JIT-compiled methods stays in CodeCache until they are reclaimed. UseCodeCacheFlushing affects reclamation of cold (but still valid) compiled methods. However, CodeCache may also contain obsolete or invalidated methods ("zombies") which are subject to purge at the next sweep cycle even with -XX:-UseCodeCacheFlushing.

  • In a tiered compilation mode (default since JDK 8) a method may be compiled multiple times with a different level of optimizations. Once an optimized (tier 4) version of a method is installed, the previous version becomes obsolete and can be reclaimed after all activations of that version complete.
  • A speculatively compiled method may become invalid when the speculation fails (e.g. after a new class is loaded). Such method also becomes zombie and can be later reclaimed.
  • Another example is an OSR compilation. This is a version of a method that was compiled specially for transferring execution from interpreter to compiled code while the method is running. Answering your 3rd question, this is a kind of "temporary" method which becomes obsolete after the full version of compiled method is installed and all OSR activations complete.

There is a separate JVM flag -XX:-MethodFlushing to prevent sweeping CodeCache altogether, including zombie methods.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!