You can calculate the threshold value by keeping the value calculated with the following formula as the standard:
Threshold-value![]() ![]() |
Consider the following points when setting up the threshold value:
The relationship between the occurrence frequency of full garbage collection and the threshold value, and the method for estimating the free memory size required while waiting for cancellation of resource exclusion are as follows:
The processing of full garbage collection takes more time as compared to the execution speed of any program. Therefore, when tuning JavaVM, try to avoid the occurrence of full garbage collection as far as possible. For details about the concept of JavaVM tuning, see 7.2.1 Concept of tuning.
You must also tune in such a way so that setting up a threshold value reduces the frequency of a full garbage collection to be executed explicitly.
The following figure shows an example of memory usage for each setup threshold value:
Figure 9-2 Example of memory usage for each setup threshold value
The memory usage in JavaVM keeps increasing along with the passage of time, and reduces when full garbage collection occurs.
When you set up 0 as the threshold value, full garbage collection will not be executed until JavaVM executes it automatically. As compared to the specification of a large value, when you set up a small value as the threshold value, the frequency of occurrence of full garbage collection increases. In the figure, when 80 is set up as the threshold value, the frequency of execution of full garbage collection can be suppressed down as compared to the case where 50 is set up as the threshold value.
However, when the execution frequency of full garbage collection is reduced, the time taken for the execution of one full garbage collection becomes longer as compared to when full garbage collection is executed more frequently.
When the memory usage exceeds the threshold value, full garbage collection will not be executed until the resource exclusion is cancelled. However, while waiting for cancellation of resource exclusion, if the memory required by JavaVM becomes insufficient, full garbage collection will be executed by JavaVM without waiting for cancellation of resource exclusion.
The following figure shows an example in which the memory becomes insufficient while waiting for cancellation of resource exclusion:
Figure 9-3 Example of a case when the memory becomes insufficient while waiting for cancellation of resource exclusion
When you set up the memory size for the occurrence of full garbage collection to 100, the memory size that can be used while waiting for cancellation of resource exclusion will be 100 - Threshold value (%).
For example, if you set up a large value, such as 95 as the threshold value, the free memory size that can be used while waiting for cancellation of resource exclusion will be minimal at 5%, and therefore, full garbage collection might be executed automatically by JavaVM before the cancellation of the resource exclusion.
Therefore, when estimating the threshold value, set up a value with a considerable margin such that the memory does not become insufficient while waiting for cancellation of the resource exclusion.