什么是ReservedCodeCacheSize 和InitialCodeCacheSize?
有人可以解释一下 JVM 选项 ReservedCodeCacheSize
和 InitialCodeCacheSize
是什么吗?具体来说我什么时候/为什么要改变它?我如何确定合适的尺寸?
这就是文档所说的:
-XX:ReservedCodeCacheSize=32m 保留代码缓存大小(以字节为单位)- 最大代码缓存大小。 [Solaris 64 位、amd64 和 -server x86:2048m;在 1.5.0_06 及更早版本中,Solaris 64 位和 and64:1024m。]
Can someone please explain what the JVM option ReservedCodeCacheSize
and InitialCodeCacheSize
are? Specifically when/why would I want to change it? How do I decide what the right size is?
This is what the docs say:
-XX:ReservedCodeCacheSize=32m Reserved code cache size (in bytes) - maximum code cache size. [Solaris 64-bit, amd64, and -server x86: 2048m; in 1.5.0_06 and earlier, Solaris 64-bit and and64: 1024m.]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
ReservedCodeCacheSize
(和InitialCodeCacheSize
)是 Java Hotspot VM 的(即时)编译器的一个选项。基本上它设置了编译器代码缓存的最大大小。缓存可能已满,这会导致如下警告:
如果随后出现 Java HotSpot(TM) 客户端 VM 警告:发生异常 java.lang.OutOfMemoryError 将信号 SIGINT 分派给处理程序,情况会更糟 - VM 可能需要被强制终止。
什么时候设置这个选项?
通常您不会更改此值。我认为默认值非常平衡,因为此问题仅在极少数情况下发生(根据我的经验)。
ReservedCodeCacheSize
(andInitialCodeCacheSize
) 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:
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?
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).
@jeha 回答了我想从这个问题中知道的所有内容,除了将参数设置为什么值之外。由于我没有编写正在部署的代码,因此我对其内存占用没有太多了解。
但是,您可以使用 jconsole 附加到正在运行的 java 进程,然后使用“内存”选项卡找出代码缓存大小。为了完整起见,步骤如下(Linux VM 环境,尽管我确信其他环境也类似):
同样,屏幕刷新可能需要一些时间,然后您应该看到类似以下内容的内容:
如您所见,我的代码缓存使用了大约 49 MB。此时我仍然使用文档(和@jeha)所说的默认值 48 MB。这对我增加设置来说无疑是一个很大的动力!
本。
<小时>
默认情况下 1024 MB 可能有点过了,但默认情况下 48 MB 似乎还不够......
@jeha answers everything I wanted to know from this question, apart from what value to set the parameters to. As I didn't write the code I was deploying I didn't have much visibility into the memory footprint it had.
However, you can use jconsole to attach to your running java process, and then use the 'Memory' tab to find out the Code Cache size. For completeness, the steps are (Linux VM environment, though I'm sure other environments are similar):
Again, this may take a few moments for the screen to refresh, and then you should see something like:
As you can see, my code cache is using approx 49 MB. At this point I still had the default which the documentation (and @jeha) says is 48 MB. Certainly a great motivation for me to increase the setting!
Ben.
1024 MB by default probably was overdoing it, but 48 MB by default seems to be underdoing it...
Indeed 工程团队提供了很好的学习经验,以及他们在迁移到 jdk 8 时遇到的挑战。
http://engineering.indeedblog.com/blog/2016/09/job-search-web-app-java-8-migration/
结论:Jdk 8 需要比 JDK 7 更多的代码缓存
JRE 8 的默认代码缓存大小约为 250MB,大约比 JRE 7 的默认 48MB 大五倍。我们的经验是,JRE 8 需要额外的代码缓存。到目前为止,我们已经将大约十个服务切换到 JRE 8,所有这些服务使用的代码缓存比以前多了大约四倍。
A good learning experience from Indeed engineering team and challenges they faced when migrating to jdk 8.
http://engineering.indeedblog.com/blog/2016/09/job-search-web-app-java-8-migration/
Conclusion : Jdk 8 needs more code cache han JDK 7
The default codecache size for JRE 8 is about 250MB, about five times larger than the 48MB default for JRE 7. Our experience is that JRE 8 needs that extra codecache. We have switched about ten services to JRE 8 so far, and all of them use about four times more codecache than before.
来自https://blogs.oracle.com/poonam/entry/why_do_i_get_message:
因此,对于在 JDK 6(禁用代码刷新)和 7 上运行的系统,该信息可能值得一提。
from https://blogs.oracle.com/poonam/entry/why_do_i_get_message:
So that information might be worth mentioning for systems running on JDK 6 (having code flushing disabled) and 7.