uCosminexus Application Server, Maintenance and Migration Guide

[Contents][Glossary][Index][Back][Next]

9.4.1 Overview of the instance statistical functionality

The instance statistical functionality is used to check memory leaks in applications.

The instance statistical functionality investigates the reference relation of instances, such as relation with instances of class A->member variable of class A(the class is classB)->instances of classB->..., and recurrently adds the size of the instances without referencing to other instances in the class that has the instances as the member. In other words, the instance statistical functionality outputs the total size of the instances referenced by the class instances.

To check the cause of memory leak, execute the instance statistical functionality as follows, before and after the application processing for which you want to check the memory leak, then take the difference between the number of instances and the total size of the instances in points 1 and 3, check the amount of the increase in the numbers, and then identify the classes that are causing the memory leak.

  1. Execute the instance statistical functionality.
  2. Execute the application processing for which you want to check the memory leak.
  3. Execute the instance statistical functionality.

Note that because the instance statistical functionality recursively adds the size of all the instances referenced by each class instance, you cannot check the size of only the instances of each class (the size excludes the size of the instances being referenced).

In the instance statistical functionality, when using the Explicit management heap functionality, the output result of the class-wise statistical information changes according to whether to set the instances of the Explicit heap as a target for statistics. Furthermore, specify the -explicit option in the jheapprof command, and then execute the same command to set the instances of an Explicit heap as a target for statistics.

The following figure shows an example of an instance structure that describes the output result of each statistical target.

Figure 9-1 Example of instance structure

[Figure]

When the statistical target contains an Explicit heap, the instances a1, b1, b2, c1, and c2 becomes the target for the class-wise statistical information. When the statistical target does not contains an Explicit heap, the instances a1, b2, and c2 becomes the target for the class-wise statistical information.

The following table lists the instance count and the total size of instances for each statistical target.

Table 9-5 Instance count and total size of instances for each statistical target

Arguments of the jheapprof command Statistical target Class A Class B Class C
Instance count Total size# Instance count Total size# Instance count# Total size#
-explicit
  • Java heap
  • Permanent area
  • Explicit heap
1 122 2 22 2 2
-noexplicit
  • Java heap
  • Permanent area
1 111 1 11 1 1

#
The total size indicates the total size of the instances. The unit is bytes.

The formula for calculating the total size of the instances of each class is as follows:

In the instance statistical functionality, investigate for the reference relation of the object referred in the following order from the object that is the base. The base objects are the objects those are not investigated in other reference relation. 1., 2., and 3. indicates the priority order for investigating reference relation.

  1. Ascending order of the address within the Java heap
  2. Ascending order of the address within an Explicit management heap
  3. Ascending order of the address within the Permanent heap

When the reference destination objects are investigated, return up to the branch point, and investigate for the reference relation.

Moreover, when the reference destination objects are the objects that is the base of other reference relation, handle it as a reference destination object. Investigate for the reference relation until all the objects that are the base are lost.

When using instance statistical functionality, instance count of each class is output for number of instances. The following contents are output for the total size of instances: