估计64位Java中的最大安全JVM堆大小 [英] Estimating maximum safe JVM heap size in 64-bit Java

查看:138
本文介绍了估计64位Java中的最大安全JVM堆大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在分析有一些问题的64位Java应用程序的过程中,我注意到分析器本身(YourKit)正在使用真正庞大的内存量。我在YourKit启动脚本中得到的是:

In the course of profiling a 64-bit Java app that's having some issues, I notice that the profiler itself (YourKit) is using truly colossal amounts of memory. What I've got in the YourKit launch script is:

JAVA_HEAP_LIMIT="-Xmx3072m -XX:PermSize=256m -XX:MaxPermSize=768m"

天真地,假设有一些开销,这会让我猜到YourKit会去使用最大可能超过4 GB的东西。但是,我在PS中实际看到的是:

Naively, assuming some overhead, this would lead me to guess that YourKit is going to use a max of something maybe a bit over four GB. However, what I actually see in PS is:

USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
dmoles   31379  4.4 68.2 14440032 8321396 ?    Sl   11:47  10:42 java -Xmx3072m -XX:PermSize=256m -XX:MaxPermSize=768m -XX:+HeapDumpOnOutOfMemoryError -Dyjp.probe.table.length.limit=20000 -Xbootclasspath/a:/home/dmoles/Applications/yjp-9.5.6/bin/../lib/tools.jar -jar /home/dmoles/Applications/yjp-9.5.6/bin/../lib/yjp.jar

这是一个近14 GB的虚拟大小,驻留大小接近8 GB - 几乎是Java堆的3倍。

That's a virtual size of nearly 14 GB and a resident size of nearly 8 GB -- nearly 3x the Java heap.

现在,我的开发盒上有足够的内存来运行它,但回到原来的内存问题我正在尝试诊断:我怎么知道Java堆我有多少必须玩吗?

Now, I've got enough memory on my dev box to run this, but going back to the original memory problem I'm trying to diagnose: How do I know how much Java heap I have to play with?

显然,如果客户有16 GB物理内存,那么告诉他们设置<$ c $并不是一个好主意c> -Xmx 到16 GB。

Clearly, if the customer has, say, 16 GB physical RAM, it's not a great idea for me to tell them to set -Xmx to 16 GB.

那么一个合理的数字? 12 GB? 8 GB?

So what is a reasonable number? 12 GB? 8 GB?

我该如何估算?

推荐答案


显然,如果客户有16 GB物理RAM,那么告诉他们将-Xmx设置为16 GB并不是一个好主意。

Clearly, if the customer has, say, 16 GB physical RAM, it's not a great idea for me to tell them to set -Xmx to 16 GB.

如果客户在他/她的机器上没有运行任何其他重要事项,那么将堆大小设置为16G并不是必然一个坏主意。这取决于应用程序正在做什么。

If the customer was running nothing else significant on his/her machine, then setting the heap size to 16G isn't necessarily a bad idea. It depends on what the application is doing.


那么什么是合理的数字? 12 GB? 8 GB?

So what is a reasonable number? 12 GB? 8 GB?

理想的数字是JVM最大堆+ JVM非堆开销+ OS +其他活动应用程序工作集+缓冲区缓存工作集加起来物理内存量。但问题是这些组件中没有一个(除了最大堆大小)可以在客户机器上没有详细测量的情况下固定......而应用程序正在运行实际问题。

The ideal number would be to have "JVM max heap + JVM non-heap overheads + OS + other active applications' working sets + buffer cache working set" add up to the amount of physical memory. But the problem is that none of those components (apart from the max heap size) can be pinned down without detailed measurements on the customer's machine ... while the application is running on the actual problem.


我该怎么估计呢?

And how do I estimate it?

最重要的是,你可以T。你能做的最好的事情就是猜测...并保守。

The bottom line is that you can't. The best you can do is to guess ... and be conservative.

另一种方法是估计应用程序实际需要多少堆才能解决它所遇到的问题。解决。然后添加额外的50%或100%以使GC室有效工作。 (然后调整......)

An alternative approach is to estimate how much heap the application actually needs for the problem it is trying to solve. Then add an extra 50 or 100 percent to give the GC room to work efficiently. (And then tune ...)

这篇关于估计64位Java中的最大安全JVM堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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