Using verbose:gc

You can use -verbose:gc when running your application with no load, and again under stress, to help you set the initial and maximum heap sizes.

The -verbose:gc output is fully described in Verbose garbage collection logs. Turn on -verbose:gc and run up the application with no load. Check the heap size at this stage. This provides a rough guide to the start size of the heap (-Xms option) that is needed. If this value is much larger than the defaults (see Default settings), think about reducing this value a little to get efficient and rapid compaction up to this value, as described in mm_heapsizing_initial.html#mm_heapsizing_initial.

By running an application under stress, you can determine a maximum heap size. Use this to set your max heap (-Xmx) value.