Hitachi

uCosminexus Application Server System Design Guide


7.2.6 Configuration of memory space used by JavaVM when using serial GC and JavaVM options

This subsection explains the configuration of the memory space used by JavaVM when using serial GC, and the JavaVM options.

JavaVM uses two types of memory space; JavaVM specific area and OS specific area.

The following figure shows the configuration of the memory space used by JavaVM. The numbers in the figure correspond to the numbers in Table 7-2.

Figure 7‒7: Configuration of memory space used by JavaVM

[Figure]

The respective areas are explained below. The area formed by combining the Eden area, the Survivor and the Tenured area is called the Java heap.

Eden area

Java objects that are created by new are initially stored in the DefNew::Eden area.

Survivor area

Among the Java objects stored in the New area, the DefNew::Survivor area stores those Java objects that are not destroyed when copy GC is executed. The From space and the To space configure the Survivor area. The size of the From space and the To space is same.

Tenured area

The Tenured area is a memory space that stores Java objects that are considered to be necessary for a longer duration. The Java objects for whom a copy GC is executed more than the specified number of times in the Survivor area and that were not destroyed, are moved to this area.

Metaspace area

The Permanent area stores the information of class that has been loaded.

If the object-pointer compression function is enabled, an area called the Compressed Class Space is created in the Metaspace area. This area contains information about the classes referenced by objects in the Java heap. Other information including method information is stored in the part of the Metaspace area that is outside the Compressed Class Space. For details about the object-pointer compression function, see 9.18 Object-pointer compression function in the uCosminexus Application Server Maintenance and Migration Guide.

Explicit heap area

The Explicit heap area stores Java objects that are not subject to Full GC. The Explicit heap area is the JavaVM-specific memory space and the Explicit heap area is allocated only when using the Explicit Memory Management functionality.

C heap area

The C heap area is used by JavaVM. The C heap is also used by the native library that is called by JNI.

Reference note

Maximum size of the C heap area (In AIX)

In AIX, when you use the JNI to execute the program for invoking JavaVM, set up the maximum size of the C heap area with one of the following methods. If no method is specified, the default value of the shell datasize resource becomes the maximum size of the C heap area.

  • Specify the C heap area size in the value of the datasize resource in shell, and then execute the program.

    For csh (C shell): limit datasize C-heap-area-size

    For sh (default shell) and ksh: ulimit -d C-heap-area-size

  • Specify -bmaxdata: C-heap-area-size in the linkage option for program generation.

  • Specify the MAXDATA value in the environment variable LDR_CNTRL, and then execute the program.

    For csh (C shell): setenv LDR_CNTRL MAXDATA=C-heap-area-size

    For sh (default shell) and ksh: export LDR_CNTRL=MAXDATA=C-heap-area-size

  • Use the setrlimit() system call to implement the processing for setting up the C heap area size from within a program.

The examples includes the following area:

Code cache area

This area stores the JIT compilation code generated by JIT compilation.

JavaVM speeds up the processing by JIT compiling and executing the Java methods with a large invocation count and loop count.

Reference note

Maximum size of the code cache area

Specify the maximum size of the code cache area in the ReservedCodeCacheSize option.

Specify a value greater than the default value in the ReservedCodeCacheSize option. For details on the default value, see 14.4 Default values of the Java HotSpot VM options that can be specified in Cosminexus in the uCosminexus Application Server Definition Reference Guide.

Also, if the code cache area has depleted or might deplete, consider extending the code cache area.

Note the following points when you extend the code cache area:

  • You cannot estimate the size of the JIT compilation code by calculation. Therefore, actually measure the amount of the code cache area used in the Java application execution environment, consider the amount of the code cache area (maximum 2 MB) to be used by the system, and then estimate the maximum size of the code cache area.

  • For estimating the usage of the virtual memory, see 5.3 Estimating memory used for each process or 6.3 Estimating virtual memory usage.

Stack area

Stack area for Java threads.

Reference note

Stack area size of the main thread

To change the stack area size of the main thread, set up a value greater than the value specified in -Xss. You cannot use the -Xss option to change the stack area size of the main thread. Because the automatic start processing of a J2EE application at J2EE server startup occurs in the main thread, automatic start processing might fail. In this case, you can start the J2EE server with the -nostartapp option specified to prevent the J2EE application from starting automatically, and then manually start the J2EE application. Alternatively, you can use a Management action to start the J2EE application.

The following table describes the JavaVM options that specify the size and ratio of the respective areas. The numbers in the table correspond to the numbers in Figure 7-7.

Table 7‒2: JavaVM options for specifying the size and ratio of the JavaVM memory space

No.

Option name

Meaning of the option

1

-Xmxsize

Sets the maximum size of Java heap.

2

-Xmssize

Sets the initial size of Java heap.

3

-XX:MaxMetaspaceSize=size

Sets the maximum size of the Metaspace area.

4

-XX:MetaspaceSize=size

Sets the initial size of the Metaspace area.

5

-Xmnsize

Sets the initial value and the maximum value of the New area.

6

-XX:[+|-]HitachiAutoExplicitMemory

Allocates the memory used in Explicit memory block when starting the JavaVM using automatic allocation function.#

7

-XX:HitachiExplicitHeapMaxSize=size

Sets the maximum size of the Explicit heap area#.

8

-Xsssize

Sets the maximum size of one stack area.

9

-XX:ReservedCodeCacheSize=size

Sets the maximum size of the code cache area from among the areas used by JavaVM.

10

-XX:NewRatio=value

Sets the ratio of the Tenured area with respect to the New area.

If the value is 2, the ratio of the New area and the Tenured area becomes 1:2.

11

-XX:SurvivorRatio=value

Sets the ratio of the Eden area with respect to From space and To space of the Survivor area.

If 8 is set in value, the ratio of the Eden area, From space, and To space becomes 8:1:1.

12

-XX:TargetSurvivorRatio=value

Sets the target value for the ratio of the Survivor area occupied by Java objects after copy GC is executed.

13

-XX:MaxTenuringThreshold=value

Sets the maximum number of times to swap Java objects between the From space and the To space when executing copy GC.

The Java objects, for which the frequency of switching exceeds the set number of times, are moved to the Tenured area.

Note:

The unit of size is bytes.

#

The prerequisite options for using the Explicit Memory Management functionality must be enabled. For details, see 7.11 Explicit heap tuning.

Reference note
  • How to set JavaVM options:

    Set the JavaVM options at the following places:

    Table 7‒3: Location for setting the JavaVM options

    Target

    How to set

    Location for setting

    J2EE server

    Smart Composer functionality

    Definition file

    Easy Setup definition file

    Setup target

    Logical J2EE server (j2ee-server)

    Parameter name

    add.jvm.arg

    Batch server

    Smart Composer functionality

    Definition file

    Easy Setup definition file

    Setup target

    Logical J2EE server (j2ee-server)

    Parameter name

    add.jvm.arg

    EJB Client Application

    Edit file

    Definition file

    usrconf.cfg#

    Parameter name

    add.jvm.arg key

    #

    The file that is activated when the cjclstartap command is used for starting.

Tip

The default value of the respective options depends on the OS. For details about the default values of options, see 14.4 Default values of the Java HotSpot VM options that can be specified in Cosminexus in the uCosminexus Application Server Definition Reference Guide.

Important note

An OutOfMemory exception occurs if there is not enough space available in any of the Java heap area, Metaspace area, Compressed Class Space, or C heap area. The JavaVM will not work normally until the memory shortage is resolved, which can take some time.

By specifying the following options when OutOfMemory occurs, the impact of OutOfMemory on the system can be reduced:

  • -XX:+HitachiOutOfMemoryAbort (forceful termination when OutOfMemory occurs)

  • -XX:+HitachiOutOfMemoryHandling (OutOfMemory handling functionality)

The functionality for forceful termination when OutOfMemory occurs forcibly terminates the J2EE server when an OutOfMemory exception occurs due to an insufficient Java heap, Metaspace area, Compressed Class Space, or other memory area. When an OutOfMemory exception occurs due to an insufficient Java heap area, Metaspace area, Compressed Class Space, or C heap area, this functionality forcibly terminates the J2EE server and automatically restarts the J2EE server. This helps in fast recovery of a J2EE server so that that server can operate successfully.

OutOfMemory handling functionality is a functionality for which the functionality of forceful termination when OutOfMemory occurs is a prerequisite. Even if you are using the functionality of forceful termination when OutOfMemory occurs, you can continue the execution of J2EE server, if specific conditions are met by using this functionality.

If OutOfMemory occurs due to insufficient Java heap while allocating the large number of objects or while allocating huge objects in request processing, use the OutOfMemory handling functionality to continue the execution of J2EE server.

For details about the option, see -XX:[+|-]HitachiOutOfMemoryAbort (Forced termination option) and -XX:[+|-]HitachiOutOfMemoryHandling (OutOfMemory handling option) in the uCosminexus Application Server Definition Reference Guide.

  • Special tuning approach related to the Metaspace area

    The following explains an approach to tuning that uses the characteristics of the Metaspace area. In JDK7 and earlier, the Permanent area always used an amount of memory equivalent to the value specified in the JavaVM options, but the Metaspace area did not. In fact, the Metaspace area only uses the amount of memory required for execution.

    (a) Reducing the risk of OutOfMemoryError exceptions in the Metaspace area

    To reduce the risk of an OutOfMemoryError exception occurring due to an increase in use of the Metaspace area that was unforeseen during the estimation process, specify the estimated value plus a buffer in the -XX:MaxMetaspaceSize and -XX:CompressedClassSpaceSize options. An OutOfMemoryError exception will not occur until the usage of the Metaspace area exceeds this value.

    (b) Reducing the risk of the Metaspace area triggering Full GC

    To reduce the risk of triggering Full GC due to an increase in use of the Metaspace area that was unforeseen during the estimation process, specify the estimated value plus a buffer in the -XX:MetaspaceSize, -XX:MaxMetaspaceSize, and -XX:CompressedClassSpaceSize options. Usage of the Metaspace area will not trigger Full GC until this value is exceeded.