无法为对象堆保留足够的空间 [英] Couldn't reserve enough space for object heap
问题描述
我用Java达到了一个奇怪的内存限制.下面,我使用不同的堆大小执行"java -version".一旦将堆设置为超过30M,java就会错误退出,并抱怨没有可用内存.
I'm hitting a strange memory limit with java. Below I execute "java -version" with different heap sizes. Once I set the heap to anything over 30M, java exits with error, complaining there is no free memory.
# /usr/java/default/bin/java -Xmx30m -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
# /usr/java/default/bin/java -Xmx40m -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
# An error report file with more information is saved as:
# /root/hs_err_pid6689.log
# /usr/java/default/bin/java -Xmx50m -version
Error occurred during initialization of VM
java.lang.OutOfMemoryError: unable to create new native thread
# /usr/java/default/bin/java -Xmx60m -version
#
# There is insufficient memory for the Java Runtime Environment to continue.
# pthread_getattr_np
# An error report file with more information is saved as:
# /root/hs_err_pid6703.log
根据免费",我有很多可用RAM:
According to "free" I have lots of free RAM:
# free -m
total used free shared buffers cached
Mem: 2909 1051 1858 0 17 618
-/+ buffers/cache: 415 2494
Swap: 511 0 511
但是从我看来,这显然是内存限制问题.当我杀死一些后台进程时,可以为"java -version"命令分配更多的堆.
But from what I see this clearly is a memory limit issue. When I kill some background processes, I can assign more heap to "java -version" command.
有人知道发生了什么事吗?
Does anyone know what's happening?
推荐答案
我正在回答自己的问题(以防万一有人碰到类似问题).
I'm answering my own question (just in case someone bumps into a similar issue).
在我的系统上,我在/etc/sysctl.conf
On my system I had this in /etc/sysctl.conf
vm.overcommit_memory = 2
将其重新设置为默认值(0)已解决了该问题:
Setting it back to its default value (0) has resolved the issue:
vm.overcommit_memory = 0
这篇关于无法为对象堆保留足够的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!