SAP Basis/Netweaver Tutorials, Monitoring, Administration(Certification) and FAQs Headline Animator

SAP Basis/Netweaver Tutorials, Monitoring, Administration(Certification) and FAQs


Tuesday, 16 July 2013

Explain Java Virtual Memory in SAP

This article answers following queries :

Explain memory management of Java Virtual Machine(JVM) in SAP
Explain JVM memory areas in SAP
Explain Young generation, Tenured generation and Permanent Generations
How to maintain JVM parameters  in SAP?
Which tool is used to configure Java VM settings in SAP?
How JVM automatically takes care of memory allocation?
Explain Used memory, Allocated memory, Virtual memory

----------------------------------------------------------------------------------


The JVM automatically takes care of allocation of memory space for java applications.

A “generation” reserves space in the address area of the host.

While starting sap system, the java virtual machine allocates operating system memory for each of the generations. This initially allocated memory is termed as “initial” or “initial size”. After complete usage of initial size, the java virtual machine further allocates memory in stages upto a maximum defined value termed as “max size”.

The memory space that is available is called the available memory or allocated memory. Since this space is reserved by the operating system, it is also called as “reserved space”. The space that is not reserved is called as “virtual memory”. 

The “ reserved space”  is available to the JVM. However, not all the memory is used always. It will be used based on the requirement. The memory that is actually used by the java applications is termed as “used memory”. If less space is required by the java application, the memory is returned to the operating system in stages. 

The memory area of JVM is mainly divided into 3 areas as listed below
Young generation
Tenured generation
Permanent generation

The 3 memory areas Young, Tenured and Permanent differ based on the data stored in them. Each of these generations has an initial and maximum size.

Young Generation : The objects that have been newly created by the applications are stored in the younger generation.

For younger generation, we can define initial size and maximum size with the parameters  -XX:NewSize and –XX:MaxNewSize respectively

 Tenured Generation: The objects that have been required for a longer period of time by an application are automatically moved to the tenured generation
For tenured generation, we cannot directly set initial size and maximum size directly. These are calculated from the parameters of the younger generation and the parameters  –Xms and  –Xmx.

The parameter –Xms is the “start heap size” or “initial heap size” and it defines the total initial size of the young and tenured generations.

The parameter  -Xmx is the “max heap size” and it defines the total size of the young and tenured generations.

So indirectly, it means that 
Initial size of tenured generation =  (-Xms)  -  (-XX:NewSize)
Maximum size of tenured generation = (-Xmx) – (–XX:MaxNewSize)

Permanent Generation : The objects that are permanently required by the JVM such as classes and objects are stored in the Permanent Generation.

For permanent generation, we can define initial size and maximum size with the parameters –XX:PermSize and  –XX:MaxPermSize respectively

Config Tool is the only tool used to set JVM parameters in an SAP java system.