简体   繁体   中英

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. For some reason, it does not work if I specify more than 19G of RAM for the process. The free and top show that I have 23G of free memory, so I wonder why this error occurs.

           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:

-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.

The Java VM allocates memory for the heap as well as for PermGen space. Can it be that your configuration with heap space + PermGen space exceeds your free memory?

Which value is -XX:MaxPermSize set to?

Extracted from java docs:

" 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 ".

it also sounds like you should review whatever that process does if it needs to take up to 22gb's of 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

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)

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

HTH jerome

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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