How to do heap sizing
You can do heap sizing to suit your requirements.
If you do not set an initial or maximum heap size, the GC expands and shrinks the heap as required. This capability allows for situations where usage varies over time or exceeds an expected maximum heap size for your application. However, you can choose not to have a variable heap but to set the Java™ heap size for your application. There are advantages and disadvantages to setting a fixed heap and the decision to use one depends on the application you are running.
Generally:
- Do not start with a minimum heap size that is the same as the maximum heap size.
- Use a tool to check your application heap size and determine the minimum and maximum settings. Alternatively, you can use the output from -verbose:gc to tailor the minimum and maximum settings.
- Investigate the use of fine-tuning options.