使用大量内存的 Java 应用程序.使用-Xmx? [英] Java app that uses a lot of memory. Use -Xmx?

查看:22
本文介绍了使用大量内存的 Java 应用程序.使用-Xmx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 java 应用程序,它在 16G 的机器上使用大约 15G.我不知道是否应该设置最大堆大小.

如果设置了 jvm 是否会吃掉所有的内存,然后开始垃圾收集并在它翻腾 15G 的堆对象时停止一切?

如果不是这样,jvm 会因为不使用机器上所有可用的内存而损害性能.

我的特定虚拟机是:Java HotSpot(TM) 64 位服务器虚拟机(内部版本 1.6.0_03-b05,混合模式).

谢谢

解决方案

-Xmx15G 将最大堆大小设置为 15 gig.Java 只会在运行时分配它需要的东西.如果不设置,它只会使用默认值.有关默认值的信息,请参阅这篇文章.p>

-Xms15G 将最小堆设置为 15 gig.这会强制 java 在开始执行之前分配 15 gig 的堆空间,无论它是否需要.

通常您可以将它们都设置为适当的值,具体取决于您调整 JVM 的方式.

I have a java app that uses about 15G on a machine with 16G. I don't know if I should set the max heap size.

If set will the jvm eat all the ram up to the limit and then start garbage collecting and stop everything while it churns through 15G of heap objects?

If not will the jvm hurt performance by not using all of the available ram on the machine.

My specific vm is: Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode).

Thanks

解决方案

-Xmx15G will set the maximum heap size to 15 gig. Java will only allocate what it needs as it runs. If you don't set it, it will only use the default. For info on the default, see this post.

-Xms15G sets the minimum heap to 15 gig. This forces java to allocate 15 gig of heap space before it starts executing, whether it needs it or not.

Usually you can set them both to appropriate values depending on how you're tuning the JVM.

这篇关于使用大量内存的 Java 应用程序.使用-Xmx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆