如果没有在OSX捆绑包上指定,Java7如何决定分配的堆内存的最大值(-Xmx),我已经阅读了手册页,它没有给出任何指示。它似乎被分配比默认Java6和我想知道它是否随可用存储器的机器上这将是非常有用的我因为我的应用程序是内存绑定但我不能设置默认太高,因为这样应用程序将无法在较低规格的机器上运行。
来自openjdk源代码的默认堆大小
从源复制评论
// If the maximum heap size has not been set with -Xmx,
// then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap.
分数=4
product(uintx, MaxRAMFraction, 4, \
"Maximum fraction (1/n) of real memory used for maximum heap " \
"size") \
\
product(uintx, DefaultMaxRAMFraction, 4, \
"Maximum fraction (1/n) of real memory used for maximum heap " \
"size; deprecated: to be renamed to MaxRAMFraction") \
关于mx的完整代码
void Arguments::set_heap_size() {
if (!FLAG_IS_DEFAULT(DefaultMaxRAMFraction)) {
// Deprecated flag
FLAG_SET_CMDLINE(uintx, MaxRAMFraction, DefaultMaxRAMFraction);
}
const julong phys_mem =
FLAG_IS_DEFAULT(MaxRAM) ? MIN2(os::physical_memory(), (julong)MaxRAM)
: (julong)MaxRAM;
// If the maximum heap size has not been set with -Xmx,
// then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap.
if (FLAG_IS_DEFAULT(MaxHeapSize)) {
julong reasonable_max = phys_mem / MaxRAMFraction;
if (phys_mem <= MaxHeapSize * MinRAMFraction) {
// Small physical memory, so use a minimum fraction of it for the heap
reasonable_max = phys_mem / MinRAMFraction;
} else {
// Not-small physical memory, so require a heap at least
// as large as MaxHeapSize
reasonable_max = MAX2(reasonable_max, (julong)MaxHeapSize);
}
if (!FLAG_IS_DEFAULT(ErgoHeapSizeLimit) && ErgoHeapSizeLimit != 0) {
// Limit the heap size to ErgoHeapSizeLimit
reasonable_max = MIN2(reasonable_max, (julong)ErgoHeapSizeLimit);
}
if (UseCompressedOops) {
// Limit the heap size to the maximum possible when using compressed oops
julong max_coop_heap = (julong)max_heap_for_compressed_oops();
if (HeapBaseMinAddress + MaxHeapSize < max_coop_heap) {
// Heap should be above HeapBaseMinAddress to get zero based compressed oops
// but it should be not less than default MaxHeapSize.
max_coop_heap -= HeapBaseMinAddress;
}
reasonable_max = MIN2(reasonable_max, max_coop_heap);
}
reasonable_max = os::allocatable_physical_memory(reasonable_max);
if (!FLAG_IS_DEFAULT(InitialHeapSize)) {
// An initial heap size was specified on the command line,
// so be sure that the maximum size is consistent. Done
// after call to allocatable_physical_memory because that
// method might reduce the allocation size.
reasonable_max = MAX2(reasonable_max, (julong)InitialHeapSize);
}
if (PrintGCDetails && Verbose) {
// Cannot use gclog_or_tty yet.
tty->print_cr(" Maximum heap size " SIZE_FORMAT, reasonable_max);
}
FLAG_SET_ERGO(uintx, MaxHeapSize, (uintx)reasonable_max);
}
// If the initial_heap_size has not been set with InitialHeapSize
// or -Xms, then set it as fraction of the size of physical memory,
// respecting the maximum and minimum sizes of the heap.
if (FLAG_IS_DEFAULT(InitialHeapSize)) {
julong reasonable_minimum = (julong)(OldSize + NewSize);
reasonable_minimum = MIN2(reasonable_minimum, (julong)MaxHeapSize);
reasonable_minimum = os::allocatable_physical_memory(reasonable_minimum);
julong reasonable_initial = phys_mem / InitialRAMFraction;
reasonable_initial = MAX2(reasonable_initial, reasonable_minimum);
reasonable_initial = MIN2(reasonable_initial, (julong)MaxHeapSize);
reasonable_initial = os::allocatable_physical_memory(reasonable_initial);
if (PrintGCDetails && Verbose) {
// Cannot use gclog_or_tty yet.
tty->print_cr(" Initial heap size " SIZE_FORMAT, (uintx)reasonable_initial);
tty->print_cr(" Minimum heap size " SIZE_FORMAT, (uintx)reasonable_minimum);
}
FLAG_SET_ERGO(uintx, InitialHeapSize, (uintx)reasonable_initial);
set_min_heap_size((uintx)reasonable_minimum);
}
}
我的java actvemq进程的配置如下,其中Xmx为15360M,但当我使用glance查看进程内存使用情况时,我看到RSS 41.8gb和VSS 51.6gb。pmap | grep total给了我总计54059348K。我不确定activemq中发生了什么,导致占用了这么多内存。而堆使用率很低,只有60%。 在pmap的输出中,我看到了许多anon块。请查看随附的PMAP输出 请在此处找
我使用的计算机规格如下:OS-Windows7 professional Installed Memory(RAM):8Gb系统类型:64位操作系统JVM:Java version 8 update 91(jre1.8.0_91)64位版本 Java版本"1.8.0_91"Java(TM)SE运行时环境(内部版本1.8.0_91-b15)JavaHotSpot(TM)64位服务器VM(内部版本25
我试图了解分配给堆栈和堆的内存量。假设sizeof(char)=1字节,sizeof(void*)=4字节。给定以下代码: 我们被告知分配给堆的内存量是5个字节,我明白这确实是malloc(strlen(str2)=5)中的量。但是,我不明白的是分配给堆栈的内存量是如何达到18个字节的?我想如果他们给我们一个指针大小是4个字节的信息,那么我们有4个字节的指针str1和另外6个字节的数组str2(包
本文向大家介绍eclipse 增加Eclipse的最大堆内存,包括了eclipse 增加Eclipse的最大堆内存的使用技巧和注意事项,需要的朋友参考一下 示例 要增加Eclipse使用的最大堆内存量,请编辑eclipse.iniEclipse安装目录中的文件。 该文件指定用于启动Eclipse的选项,例如要使用的JVM,以及JVM的选项。具体来说,您需要编辑-XmxJVM选项的值(如果不存在,请
我们有一个需求,即应用程序jvm总内存太高,并且根据输入数据集而变化。因此我们不知道要使用-xmx命令行选项设置的最大堆大小。所需的总内存大于默认的最大堆大小(总物理内存的1/4)。 当我们没有给出任何GC人体工程学命令行参数时,内存在9-9.5GB(系统中的总物理内存为38GB)之后没有增长。而应用程序就会在这一点上卡住。 如果我们将Xmx值设为20 GB,则应用程序正在运行。但是我们不确定最大
问题内容: 是局部变量,将其存储在堆或堆栈中的何处? 问题答案: 在堆上。每当您用来创建对象时,它都会在堆上分配。