Java拒绝启动 - 无法为对象堆保留足够的空间 [英] Java Refuses to Start - Could not reserve enough space for object heap

查看:401
本文介绍了Java拒绝启动 - 无法为对象堆保留足够的空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们拥有大约20个Linux刀片服务器。有些正在运行Suse,有些正在运行Redhat。 ALL共享NAS空间,其中包含以下3个文件夹:

We have a pool of aproximately 20 linux blades. Some are running Suse, some are running Redhat. ALL share NAS space which contains the following 3 folders:


  • / NAS / app / java - 指向Java安装的符号链接JDK。目前版本1.5.0_10

  • / NAS / app / lib - 指向我们应用程序版本的符号链接。

  • / NAS / data - 写入输出的目录

我们所有的机器都有2个处理器(超线程),4GB物理内存和4GB交换空间。我们将每台机器在给定时间可以处理的作业数量限制为6(这个数字可能需要更改,但这不会进入当前问题,所以请暂时忽略它。)

All our machines have 2 processors (hyperthreaded) with 4gb of physical memory and 4gb of swap space. We limit the number of 'jobs' each machine can process at a given time to 6 (this number likely needs to change, but that does not enter into the current problem so please ignore it for the time being).

我们的一些工作将最大堆大小设置为512mb,其他一些则保留最大堆大小为2048mb。同样,我们意识到如果在堆大小设置为2048的同一台机器上启动了6个作业,我们可以查看可用内存,但据我们所知,这还没有发生。

Some of our jobs set a Max Heap size of 512mb, some others reserve a Max Heap size of 2048mb. Again, we realize we could go over our available memory if 6 jobs started on the same machine with the heap size set to 2048, but to our knowledge this has not yet occurred.

一旦有一段时间作业将立即失败,并显示以下消息:

Once and a while a Job will fail immediately with the following message:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

我们过去常常在同一台机器上同时运行太多的作业。这个问题很少发生( MAYBE 每月一次),我们只是重启它,一切都会好的。

We used to chalk this up to too many jobs running at the same time on the same machine. The problem happened infrequently enough (MAYBE once a month) that we'd just restart it and everything would be fine.

问题最近出现了变得更糟。我们所有要求最大堆大小为2048m的作业几乎每次都会立即失败,并且需要在完成之前重新启动几次。

The problem has recently gotten much worse. All of our jobs which request a max heap size of 2048m fail immediately almost every time and need to get restarted several times before completing.

我们已经去了单独的机器并试图用相同的结果手动执行它们。

We've gone out to individual machines and tried executing them manually with the same result.

事实证明问题只存在于我们的SuSE盒子。它更频繁发生的原因是因为我们一直在增加更多的机器,而新的机器是SuSE。

It turns out that the problem only exists for our SuSE boxes. The reason it has been happening more frequently is becuase we've been adding more machines, and the new ones are SuSE.

SuSE框上的'cat / proc / version'给我们:

'cat /proc/version' on the SuSE boxes give us:

Linux version 2.6.5-7.244-bigsmp (geeko@buildhost) (gcc version 3.3.3 (SuSE Linux)) #1 SMP Mon Dec 12 18:32:25 UTC 2005



RedHat盒子上的'cat / proc / version'给我们:

'cat /proc/version' on the RedHat boxes give us:

Linux version 2.4.21-32.0.1.ELsmp (bhcompile@bugs.build.redhat.com) (gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-52)) #1 SMP Tue May 17 17:52:23 EDT 2005

'uname -a'给出了以下内容两种类型的机器:

'uname -a' gives us the following on BOTH types of machines:

UTC 2005 i686 i686 i386 GNU/Linux

机器上没有正在运行的作业,也没有其他进程占用太多内存。当前运行的所有进程可能总共使用100mb。

No jobs are running on the machine, and no other processes are utilizing much memory. All of the processes currently running might be using 100mb total.

'top'目前显示以下内容:

'top' currently shows the following:

Mem:   4146528k total,  3536360k used,   610168k free,   132136k buffers
Swap:  4194288k total,        0k used,  4194288k free,  3283908k cached

'vmstat'目前显示以下内容:

'vmstat' currently shows the following:

procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----
r  b   swpd   free   buff  cache   si   so    bi    bo   in    cs us sy id wa
0  0      0 610292 132136 3283908    0    0     0     2   26    15  0  0 100  0

如果我们使用以下命令行(最大堆为1850mb)启动作业,它就会正常启动:

If we kick off a job with the following command line (Max Heap of 1850mb) it starts fine:

java/bin/java -Xmx1850M -cp helloworld.jar HelloWorld
Hello World

如果我们将最大堆大小提升到1875mb它就会失败:

If we bump up the max heap size to 1875mb it fails:

java/bin/java -Xmx1875M -cp helloworld.jar HelloWorld
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

很明显当前使用的内存用于缓冲/缓存,这就是为什么这么少显示为免费。不清楚的是为什么有一个神奇的1850mb线,任何更高的意味着Java无法启动。

It's quite clear that the memory currently being used is for Buffering/Caching and that's why so little is being displayed as 'free'. What isn't clear is why there is a magical 1850mb line where anything higher means Java can't start.

任何解释都将不胜感激。

Any explanations would be greatly appreciated.

推荐答案

您使用的是32位操作系统,因此您将看到总大小的限制。其他答案已经更详细地介绍了这一点,所以我将避免重复他们的信息。

You're using a 32-bit OS, so you're going to be seeing limits on the total size due to that. Other answers have covered this in more detail, so I'll avoid repeating their information.

我最近注意到我们服务器的一个行为是指定最大堆大小 -Xmx 虽然未使用 -Xms 指定最小堆大小,但会导致Java的服务器VM立即尝试分配全部最大堆大小所需的内存。当然,如果应用程序达到堆大小,那就是你需要的内存量。但是很有可能,你的应用程序将以相对较小的堆开始,而可能需要更大的堆。另外,指定最小堆大小将允许您以较小的堆启动应用程序并逐渐增大该堆。

A behaviour that I noticed with our servers recently is that specifying a maximum heap size with -Xmx while not specifying a minimum heap size with -Xms would lead to Java's server VM immediately attempting to allocate all of the memory needed for the maximum heap size. And sure, if the app gets up to that heap size, that's the amount of memory that you'll need. But the chances are, your apps will be starting out with comparitively small heaps and may require the larger heap at some later point. Additionally specifying the minimum heap size will let you start your app start with a smaller heap and gradually grow that heap.

所有这些都不会帮助您增加最大堆大小,但我认为它可能会有所帮助,所以......

All of this isn't going to help you increase your maximum heap size, but I figured it might help, so...

这篇关于Java拒绝启动 - 无法为对象堆保留足够的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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