What are ReservedCodeCacheSize and InitialCodeCacheSize?

后端 未结 4 838
你的背包
你的背包 2020-11-29 18:56

Can someone please explain what the JVM option ReservedCodeCacheSize and InitialCodeCacheSize are? Specifically when/why would I want to change it?

4条回答
  •  盖世英雄少女心
    2020-11-29 19:14

    ReservedCodeCacheSize (and InitialCodeCacheSize) is an option for the (just-in-time) compiler of the Java Hotspot VM. Basically it sets the maximum size for the compiler's code cache.

    The cache can become full, which results in warnings like the following:

    Java HotSpot(TM) 64-Bit Server VM warning: CodeCache is full. Compiler has been disabled.
    Java HotSpot(TM) 64-Bit Server VM warning: Try increasing the code cache size using -XX:ReservedCodeCacheSize=
    Code Cache  [0x000000010958f000, 0x000000010c52f000, 0x000000010c58f000)
     total_blobs=15406 nmethods=14989 adapters=362 free_code_cache=835Kb largest_free_block=449792
    

    It's much worse when followed by Java HotSpot(TM) Client VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal SIGINT to handler- the VM may need to be forcibly terminated.

    When to set this option?

    1. when having Hotspot compiler failures
    2. to reduce memory needed by the JVM (and hence risking JIT compiler failures)

    Normally you'd not change this value. I think the default values are quite good balanced because this problems occur on very rare occasions only (in my experince).

提交回复
热议问题