简体   繁体   English

系统具有足够的内存,但“无法为对象堆保留足够的空间”

[英]The system has enough memory but “Could not reserve enough space for object heap”

I am tryiung to start a java process that requires a lot of memory. 我正在尝试启动一个需要大量内存的Java进程。 For some reason, it does not work if I specify more than 19G of RAM for the process. 由于某种原因,如果我为该进程指定了超过19G的RAM,它将无法正常工作。 The free and top show that I have 23G of free memory, so I wonder why this error occurs. free和top表示我有23G的空闲内存,所以我想知道为什么会发生此错误。

           total       used       free     shared    buffers     cached
Mem:         24158       1047      23111          0         16        356
-/+ buffers/cache:        673      23485
Swap:         2204          0       2204

Starting the process with these jvm options: 使用以下jvm选项启动该过程:

-XX:+UseConcMarkSweepGC -server -d64 -Xms4g -Xmx22g

version: 版:

java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
Java HotSpot(TM) 64-Bit Server VM (build 22.0-b10, mixed mode)

However, if I specify 19G as Xmx it works. 但是,如果我将19G指定为Xmx,则可以使用。

The Java VM allocates memory for the heap as well as for PermGen space. Java VM为堆以及PermGen空间分配内存。 Can it be that your configuration with heap space + PermGen space exceeds your free memory? 可能是您的堆空间+ PermGen空间配置超出了您的可用内存吗?

Which value is -XX:MaxPermSize set to? -XX:MaxPermSize设置为哪个值?

Extracted from java docs: 从Java文档中提取:

" Typically, for any platform you don't want to use a larger maximum heap size setting than 75% of the available physical memory. This is because you need to leave some memory space available for internal usage in the JVM ". 通常,对于任何平台,您都不想使用大于可用物理内存的75%的最大堆大小设置。这是因为您需要保留一些内存空间供JVM内部使用 ”。

it also sounds like you should review whatever that process does if it needs to take up to 22gb's of ram 这听起来也像您需要检查该过程所做的任何事情(如果它需要占用22GB的RAM)

yes you are facing a memory layout problem because doing an approximate computation: size of the process (as seen by your Unix machine) = size of the process nude + size of the heap + size of the perm gen + size of stack 是的,您因为执行近似的计算而面临内存布局问题:进程的大小(如您的Unix计算机所见)=进程的大小裸体+堆的大小+ perm gen的大小+堆栈的大小

stack is quite small ( x Mb) size of the process (y Mb) size of the heap = what you want perm gen may depend from different parameters but packaging matters (especially with Spring applications) 堆栈的大小非常小(x Mb)进程的大小(y Mb)堆的大小=您想要的perm gen可能取决于不同的参数,但打包问题(尤其是Spring应用程序)

Don't forget to leave enough memory to your Unix machine (stop all unused services) to avoid swapping which won't help you much in production 不要忘了给Unix机器留下足够的内存(停止所有未使用的服务),以避免交换,这对生产无济于事。

HTH jerome HTH热罗姆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM