In our project we use Tomcat 7 server and we need to increase our Heap size up to 6 gb. Some processes in our project uses this memory.After our processes finished we apply garbage collection in our code. We follow memory allocation using Java VisualVM. There is a problem. When our processes finished, used heap size decreases but Heap size that JVM provide (6gb) doesn't decrease so our local computers have some difficulties to handle new processes.So my question is, is there a way to decrease Heap size to used heap size level? How can we manage that. I hope i can ask my situation clearly. Thanks in advice.
Asked
Active
Viewed 285 times
2 Answers
4
This behavior varies between implementations, but the default Sun/Oracle behavior would (eventually) return (some) memory to the OS (maybe). The defaults can be changed with -XX:MinHeapFreeRatio=<minimum> and -XX:MaxHeapFreeRatio=<maximum>.
By default, the virtual machine grows or shrinks the heap at each collection to try to keep the proportion of free space to live objects at each collection within a specific range.

Elliott Frisch
- 198,278
- 20
- 158
- 249
-
For curiosity sake, if that ratio is set to a low ratio, could it cause performance issues (given that the JVM may constantly have to reallocate Heap)? – user3507600 May 29 '14 at 17:32
-
Thanks i will try it. But what values should i enter for max and min ? – mft May 29 '14 at 17:35
2
Eclipse release heap back to system
Above link helps us to solve our problem.
We add
-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=25 -Xms256m -Xmx4096m
to Tomcat VM arguments.