I have an application that can be executed when I use the jvm command -Xmx65m
. Although it is running fine, I want to allow the application to consume more memory, because it has some features that require it. The problem is that if I increase the -Xmx
option, the JVM will alocate more memory to run the features that it can handle with only 65 MB.
Is it possible to configure the JVM to only request more memory to the SO only when it is running out of options and it is about to throw an OutOfMemoryError?
Is it possible to configure the JVM to only request more memory to the SO only when it is running out of options and it is about to throw an OutOfMemoryError?
As the JVM gets close to finally running out of space, it runs the GC more and more frequently, and application throughput (in terms of useful work done per CPU second) falls dramatically. You don't want that happening if you can avoid it.
There is one GC tuning option that you could use to discourage the JVM from growing the heap. The -XX:MinHeapFreeRatio
option sets the "minimum percentage of heap free after GC to avoid expansion". If you reduce this from the default value of 40% to (say) 20% the GC will be less eager to expand the heap.
The down-side is that if you reduce -XX:MinHeapFreeRatio
, the JVM as a whole will spend a larger percentage of its time running the garbage collector. Go too far and the effect could possibly be quite severe. (Personally, I would not recommend changing this setting at all ... )