Hitachi

uCosminexus Application Server Expansion Guide


7.12.2 Implementing to obtain statistics of the Explicit Memory Management functionality

This section describes the implementation for obtaining statistics of the Explicit Memory Management functionality in your application. You can debug and analyze failures by obtaining statistics.

If you have implemented the Explicit Memory Management functionality in your application, you can obtain the following information as statistics:

Also, you can execute the following processes as processes associated with obtaining statistics:

This subsection describes the implementation of each process that uses the Explicit Memory Management functionality API.

Organization of this subsection

(1) Obtaining the status of using the Explicit heap

This point describes how to obtain information of the Explicit heap. The Explicit heap represents all Explicit memory blocks. For details on how to obtain information of each Explicit memory block, see (3) Obtaining information of Explicit memory block.

Used API

getMemoryUsage()

This API creates an instance of the java.lang.management.MemoryUsage class and returns the instance.

Information described in the following table is set in each field in the returned instance, as the information at the time of creating the instance.

Table 7‒10: Information in each field (instance of MemoryUsage class)

Field

Setting details

init

0

used

Used memory size of the Explicit heap (units: bytes)

committed

Secured size of the Explicit heap (units: bytes)

max

Maximum Explicit heap size specified in -XX:HitachiExplicitHeapMaxSize (units: bytes)

However, the value is 0 if the Explicit Memory Management functionality is OFF (if -XX:-HitachiUseExplicitMemory is set)

The following figure shows the values shown by each field.

Figure 7‒24: Values shown by each field (instance of MemoryUsage class)

[Figure]

(2) Explicit memory block size represented by ExplicitMemory instance

Obtain the Explicit memory block size that is represented by the ExplicitMemory instance, as the status of using Explicit memory block. By using the Explicit memory block size, you can check the status of using the memory in the Explicit Memory Management functionality.

Used API
  • freeMemory()

  • usedMemory()

  • totalMemory()

The following table describes the status of using Explicit memory block that you can obtain with each API. You can obtain the size as a long type value.

Table 7‒11: Status of using Explicit memory block that you can obtain with each API

API

Status of using Explicit memory block that you can obtain

freeMemory()

Usable memory size (units: bytes)

usedMemory()

Used memory size (units: bytes)

totalMemory()

Total secured size (units: bytes)

The following figure shows the values that you can obtain with each API.

Figure 7‒25: Values that you can obtain with each API

[Figure]

(3) Obtaining information of Explicit memory block

Obtain the number of the Explicit memory blocks that have an entity in the Explicit heap. The released or invalid Explicit memory blocks are not targeted. If you obtain the number of valid Explicit memory blocks, you can calculate the average memory size used in each Explicit memory block.

Used API

countExplicitMemories()

This API counts the number of memory blocks in the Explicit heap and returns it as a value of the int type. The Explicit memory blocks meeting the conditions are targeted for counting.

(4) Setting and obtaining name of the Explicit memory block

You can set name to an instance corresponding to the Explicit memory block. You can also obtain the set name. An Explicit memory block instance has a name for easy handling in an application. An instance becomes easy to use if you set a name to it.

The set value is also output in an event log of the Explicit Memory Management functionality.

Used API
  • setName()

    This API sets name.

  • getName()

    This API obtains name.

If you do not set a name in your application, the following default name is set.

BasicExplicitMemory-<ID>

ID is a value managed by JavaVM.

Important note

When naming an Explicit memory block, do not use a name starting with "CCC#". The J2EE server uses names starting with "CCC#".

The J2EE server uses the following Explicit memory block names:

  • CCC#HttpSession

    It is an Explicit memory block that places an HTTP session.

  • CCC#HttpSessionManager

    It is an Explicit memory block that places the objects for managing an HTTP session.

(5) Determining whether the Explicit memory block is processable

The Explicit memory block might become non-processable in cases such as failure in securing memory. You can determine whether an Explicit memory block is processable.

Used API

isActive()

The following table describes the mapping of the status of the Explicit memory block (ExplicitMemory instance), when the API is invoked, and the return value of the API.

Table 7‒12: Mapping of the status of the Explicit memory block when isActive() is invoked and the return value of the API

Status of Explicit memory block

Sub-status

Return value

Released

--

false

Invalid

--

false

Reserved for releasing

--

false

Valid

Enable

true

Disable

false

Legend:

--: Not applicable

(6) Determining whether the Explicit memory block can be reserved for release

You can refer to the ExplicitMemory instance corresponding to an Explicit memory block even after the Explicit memory block is reserved for releasing or released. You can check the status of the Explicit memory instance from an application by using the API.

Used API

isReclaimed()

The following table describes the mapping of the status of the Explicit memory block (ExplicitMemory instance), when the API is invoked, and the return value of the API.

Table 7‒13: Mapping of the status of the Explicit memory block when isReclaimed() is invoked and the return value of the API

Status of Explicit memory block

Sub-status

Return value

Released

--

true

Invalid

--

true

Reserved for releasing

--

true

Valid

Enable

false

Disable

false

Legend:

--: Not applicable