Reputation: 329
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.
Upvotes: 0
Views: 318
Reputation: 329
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.
Upvotes: 2
Reputation: 201399
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.
Upvotes: 4