Garbage collection analysis tools | Determining maximum heap size
6.4.2 Determine initial heap size
Running an application on WAS using the default heap size settings is not usually recommended.
Processing time is wasted expanding the heap up to the normal operating size. It is generally a good idea to set the initial heap size close to the actual size that the application will operate at.
An optimal application would have an initial and maximum heap of the same size; in fact, for performance testing, the initial and maximum heap sizes should be the same. But most applications are dynamic in nature, so a heap that fluctuates in size is expected.
Starting too small will result in too much time spent in heap expansion. Starting with too large a value may result in a fragmented heap because a collection may not occur until after a long period of time. Remember that a collection only occurs after an allocation failure happens.
To determine an appropriate initial heap size for an application, an administrator will need to know the approximate runtime values of the heap. A test run under normal load in a production-like environment will provide these numbers. The heap size may vary quite a bit, but a good sense of the average range will become apparent.
A useful starting point is to set the initial heap size to be at the low end of the range discovered during the test run. This method balances the cost of heap expansion against the possibility of a fragmented heap due to too large a setting.
To set the initial heap size using the WAS console, enter the size (in megabytes) into the Initial Heap Size field on the Java Virtual Machine settings page.