Possible Duplicate:
How to set the maximum memory usage for JVM?
I am running a java program but when the memory usage reaches 26.1%, it does not increase any more and the program gets very slow.
What could be the problem? Does java have a limit of memory usage? or is there a limit of memory per app on linux?
java version “1.7.0_11”
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)
Tasks: 126 total, 1 running, 125 sleeping, 0 stopped, 0 zombie
Cpu(s): 97.5%us, 0.4%sy, 0.0%ni, 2.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 33018800k total, 9522548k used, 23496252k free, 12100k buffers
Swap: 32764528k total, 0k used, 32764528k free, 391812k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3463 wonn24 20 0 8769m 8.2g 9.8m S 391.3 26.1 257:09.24 java
3725 hong8e 20 0 14876 1148 872 R 0.3 0.0 0:01.81 top
1 root 20 0 4088 972 720 S 0.0 0.0 0:00.71 init
2 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0.0 0.0 0:00.17 migration/0
4 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
5 root RT -5 0 0 0 S 0.0 0.0 0:00.00 watchdog/0
6 root RT -5 0 0 0 S 0.0 0.0 0:00.15 migration/1
7 root 15 -5 0 0 0 S 0.0 0.0 0:00.00 ksoftirqd/1
By default, the server version of Java has a maximum heap size of 1/4 of the main memory. With a little overhead of libraries and thread stacks this could easily be 26 or 27% of main memory.
When your JVM starts to fill up, it takes lower to perform a GC, and the lower free memory means it also occurs more often (so really bad) Ideally, you actual usage might as low as 40% of your maximum size. In your case you actual usage could be at least 7 GB.
I suggest you try increasing your maximum heap size to at least 16 GB, possibly 24 GB if you can spare the memory. i.e.
-Xmx16gor-Xmx24g