Friday, May 29, 2009

Memory Management in the VM Container

Prerequisites

You must be familiar with basic terminology related to memory management. You can find a summary of the terms in Memory Management: Basic Terms.

Concept

The shared memory is exclusively used in the VM container environment in order to convert the SAP roll-in and roll-out concept (see SAP Transactions and VM Container). Each work process can map areas of this shared resource to its address space (stable address). Only in exceptional cases would local process memory be allocated for a short time.

Note

In the following when heap (Java heap and VM heap) is mentioned, we are not referring to local process memory.

Shared Memory

When the VM container is used, shared memory is divided into the following areas:

This graphic is explained in the accompanying text

In addition to the extended memory (EM) for the ABAP context, there are the EM2 and EG2 areas.

Local VM areas (VM heap and Java heap) are contained in EM2. The shared pool used by all VMs is contained in EG2. Unlike ABAP EM, whose total size is specified by the parameter em/initial_size_MB, the sizes of EM2 and EG2 are calculated by the system and adjusted dynamically. They specify the maximum size of the shared pool and the heap.

Caution

On 32 bit platforms the address space is limited to approximately 2 GB. If you mainly use the VM container and not much ABAP, you should set a small size for the ABAP EM and the ABAP PXA buffer (abap/buffersize), so that the address space limit is not reached.

Memory Types

There are the following memory types for the VM container:

Java heap: Java objects belonging to a VM are stored on the Java heap. Each VM has its own Java heap, and other VMs cannot access them.

VM heap: The VM heap is used to store local objects such as VM Java and service stacks. It can be used only by one VM.

Shared pool: This can be used by all VMs and contains the shared Java objects (for example, shared closures, shared classes, shared code cache for compiled code).

The graphic below shows the memory areas and the connection with the most relevant Memory Parameters.

This graphic is explained in the accompanying text

The total size of the shared pool is determined in the parameter vmcj/option/ps. The area of the shared pool reserved for the compiled code of the JIT compiler is the only area that can be set explicitly with parameter vmcj/option/sharedCodeCache.

There are the following parameters for the local VM heaps:

vmcj/max_vm_heap_MB specifies the maximum size of the VM heap containing the local classes, the local code cache and the Java and service stacks.

vmcj/option/maxJavaHeap specifies the maximum size of the Java heap.

Garbage Collection

A garbage collection is run periodically on the local VM Java heap and in the shared pool.

For more information see the following sections:

Java heap: How the Local Garbage Collector Works

Shared pool: How the Shared Garbage Collector Works

End of Content Area

No comments:

Blog Archive