获取JVM以根据需要增加内存需求,达到VM限制的大小? [英] Get JVM to grow memory demand as needed up to size of VM limit?

查看:211
本文介绍了获取JVM以根据需要增加内存需求,达到VM限制的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们发布了一个Java应用程序,其内存需求可能会有很大变化,具体取决于它正在处理的数据的大小。如果你没有设置最大虚拟机(虚拟内存)大小,很多时候
JVM在大数据上退出GC失败。

We ship a Java application whose memory demand can vary quite a lot depending on the size of the data it is processing. If you don't set the max VM (virtual memory) size, quite often the JVM quits with an GC failure on big data.

d喜欢看,是JVM请求更多内存,因为GC无法提供足够的,直到总可用VM被耗尽。

What we'd like to see, is the JVM requesting more memory, as GC fails to provide enough, until the total available VM is exhausted. e.g., start with 128Mb, and increase geometrically (or some other step) whenever the GC failed.

JVM(Java)命令行允许明确设置最大虚拟机(VM),例如从128Mb开始,并在GC失败时几何增加size(各种-Xm *命令),你会认为这将是足够的。我们尝试在我们与应用程序一起提供的.cmd文件中这样做。但是如果你选择任何特定的数字
,你会得到两个不良行为之一:1)如果你的数字足够小,可以在大多数
目标系统(例如,1Gb)上工作,它不够大对于大数据,或者2)如果你使它非常大,JVM拒绝在实际VM小于指定的系统上运行。

The JVM ("Java") command line allows explicit setting of max VM sizes (various -Xm* commands), and you'd think that would be designed to be adequate. We try to do this in a .cmd file that we ship with the application. But if you pick any specific number, you get one of two bad behaviors: 1) if your number is small enough to work on most target systems (e.g., 1Gb), it isn't big enough for big data, or 2) if you make it very large, the JVM refuses to run on those systems whose actual VM is smaller than specified.

如何设置Java在需要时可以使用可用的VM,而不需要提前知道该数字,并且在启动时不需要抓取它。

How does one set up Java to use the available VM when needed, without knowing that number in advance, and without grabbing it all on startup?

推荐答案

也可以使用选项:
-XX:+ AggressiveHeap

You can also use the option: -XX:+AggressiveHeap

这根据[documentation] [1]:

This according to the [documentation][1]:


-XX:+ AggressiveHeap选项
检查机器资源(内存大小
和处理器数量)
,并尝试设置各种参数
对于长期运行,内存
分配密集型作业是最佳的。它是
最初用于具有
大容量内存和大
CPU数量的机器,但在J2SE
平台,版本1.4.1和更高版本它
显示出自己即使在
四处理器机器上也是有用的。使用这个
选项,吞吐量收集器
(-XX:+ UseParallelGC)用于沿
使用自适应大小调整
(-XX:+ UseAdaptiveSizePolicy)。
物理内存在机器上必须
至少256MB之前
AggressiveHeap可以使用。初始堆的大小
根据物理
内存的大小计算
,并尝试使
内存用于
堆的最大值即,算法尝试
使用堆大约与总
物理内存一样大。)

The -XX:+AggressiveHeap option inspects the machine resources (size of memory and number of processors) and attempts to set various parameters to be optimal for long-running, memory allocation-intensive jobs. It was originally intended for machines with large amounts of memory and a large number of CPUs, but in the J2SE platform, version 1.4.1 and later it has shown itself to be useful even on four processor machines. With this option the throughput collector (-XX:+UseParallelGC) is used along with adaptive sizing (-XX:+UseAdaptiveSizePolicy). The physical memory on the machines must be at least 256MB before AggressiveHeap can be used. The size of the initial heap is calculated based on the size of the physical memory and attempts to make maximal use of the physical memory for the heap (i.e., the algorithms attempt to use heaps nearly as large as the total physical memory).

1]: http://java.sun.com/docs/ hotspot / gc1.4.2 /#4.2.2 。 AggressiveHeap | outline

[1]: http://java.sun.com/docs/hotspot/gc1.4.2/#4.2.2. AggressiveHeap|outline

这篇关于获取JVM以根据需要增加内存需求,达到VM限制的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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