Reputation: 5203
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.
Upvotes: 1
Views: 1755
Reputation: 660
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
Upvotes: 0
Reputation: 4304
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
Upvotes: 0
Reputation: 687
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?
Upvotes: 1