Skip to main content

Heap Growing too much

1 reply [Last post]
Joined: 2006-03-29

I have an app that uses between 120 and 800 M of memory. Its pretty predictable, so that there is an operation that temporarily need 800M memory. The problem is that on profiling, I'm noticing that each time it asks for more memory, the stack grows more, even though the Max I'm using doesn't change. I've tried various tuning params, but its not helping this problem. Is there a VM argument I can set that will help this. I know maxheap seems obvious, but I want more memory available in case I need it, I just want to stop the growing when I don't.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-01-07


I guess -XX:MaxHeapFreeRatio=70 and -XX:MinHeapFreeRatio=40 is what you are looking for, the 70/40 are the default values.

MaxHeapFreeRatio means how many percent of the heap may be free until the JVM starts giving memory back to the OS. WIth the default values only if 70% or more are free, the commited heap size is shrinked.

MinHeapFreeRatio means how much has to be free after a GC cycle. e.g. if less than 40% are free, heap will grow.

However I would recommend to be careful with those setting, too strict setting will cause your app to loop the GC almost endless ;)

lg Clemens