SAP Memory Management


While working on SAP systems, we often face memory-related DUMPS in ST22 or see work processes go in PRIV mode when checked via t-code SM50. You might be wondering why such things happen in running the SAP system and how to handle it. To understand this, we first need to understand what SAP memory is and how SAP Memory Management is done. So let’s get started.

What is SAP Memory

In this article, we will focus only on the SAP ABAP system and its memory management. JAVA systems memory management, which we will discuss in a separate article.

SAP memory is a memory area to which all main sessions within an SAP GUI have access. You can use SAP memory either to pass data from one program to another within a session or to pass data from one session to another.

Workflow for SAP Memory

When a user logs on to an application server instance (AS instance) in the ABAP system, a user session is opened. Within a session, the user sends a request to Application Server ABAP (AS ABAP). An ABAP program is started that is executed by multiple work processes. A separate memory area is assigned to each user session.

To run an ABAP program within a user session (internal session), the work process allocates memory, which contains user data (user context), as well as program data. Depending on the type of data, it is located in different memory areas. SAP Memory Management decides when and in what order a work process allocates specific memory areas. The order of memory allocation depends on the work process type (dialog or non-dialog) and on the underlying operating system.

Types of SAP Memory

On a very high level, there are mainly two types of memory areas in SAP.

  • Extended Memory (EM)
  • Heap Memory

If we go a little deeper, then we have in total 6 memory areas.

  • SAP Shared Memory (SHM)
  • Extended Segments Memory (ES)
  • Extended Memory (EM)
  • Global Extended Memory (EG)
  • PRIV Memory (HEAP)
  • PROC Memory

Let’s check out these memory areas in detail.

SAP Shared Memory (SHM)

SAP shared memory is a shared memory resource in SAP Memory Management in which various buffer data are stored. SAP SHM provides a shared memory that is shared by all work processes. It is based directly on the shared memory of the operating system. It comprises SAP SHM segments that are divided into local and global segments.

  • Local SAP SHM segments can be used by all work processes of one application server instance (AS instance).
  • Global SAP SHM segments can be used by all work processes of all AS instances running on the same host.

The size of the shared memory pools is defined in the parameter ipc/shm_psize_<xx>. The parameter is valid on all operating systems. However, the creation of the pools is heavily dependent on the operating system.

Extended Segments Memory (ES)

Extended segment memory (ES) forms the basis for extended memory (EM) and global extended memory (EG). The ES consists of a limited number of segments located next to each other and can be accessed by all work processes of an application server instance (AS instance). An ES segment consists of one or more ES blocks that are all the same size. The size of the blocks is configured in the profile parameter em/blocksize_KB. The default value is 4 MB. When a user context requests a memory area from the EM, one or more blocks are allocated to the EM from the ES.

The ES blocks are stored in specific shared memory segments in the operating system. These segments are exclusively reserved for ES memory. How ES memory and therefore EM memory are implemented depends on the underlying operating system.

Extended Memory (EM)

Extended memory (EM) is the core of SAP Memory Management. The majority of data for a user session (user context), which different work processes access when processing requests, is stored here. These are mainly dialog work processes since this is where most user interaction with the system is processed. You set the size of the EM in profile parameter em/initial_size_MB.

As of the release of SAP NetWeaver 7.4, the roll area was removed. Extended memory (EM) is now the actual memory for the application data. For more information, see SAP Note 2085980.

Global Extended Memory (EG)

The global extended memory (EG) is part of the extended memory (EM). It contains user-specific data and can be accessed by all work processes. The EG is a part of the EM, which is used for multiprocessing. The EG contains data that does not belong to a specific user session. This may be data used for example for monitoring and statistics, table buffers of the database interface (DBI), or ABAP-shared objects that all work processes have access to independently of the user session.

You set the size of the EG in profile parameter em/global_area_MB.

PRIV Memory (HEAP)

The PRIV memory or HEAP memory contains data from the user context and is bound to a work process within a user session that is being executed. When a work process allocates PRIV memory, it cannot process any other user context. When the memory area is allocated from the PRIV memory, the work process is reserved for processing the current user context until the context releases the work process when the user session ends. Up to this time point, no other user context can be mapped to the work process.

HEAP memory is configured with the help of the below parameters.

  • abap/heap_area_dia
  • abap/heap_area_nondia
  • abap/heap_area_total

PROC Memory

PROC memory does not contain any user-specific data, but, like PRIV memory, is specific to the local process. Unlike the PRIV memory, the PROC memory is used for data that each work process requires, regardless of the user session, e.g. temporary, heap buffer areas. Allocation of PROC memory does not lead to an exclusive reservation of the process for a specific user context.

With profile parameter em/proc_max_size_MB, you define the maximum amount of PROC memory all work processes are allowed to occupy.


Also Read

What is Transport of Copies in SAP

Memory Area Allocation Sequence

SAP Memory area allocation sequence is different for dialog and non-dialog work processes.

Dialog Work Process

Dialog work processes are responsible for processing user requests in an ABAP system. The user context is switched frequently, which is only possible in extended memory (EM). For this reason, dialog work processes first allocate a memory area from the EM. The EM is available to work processes until the maximum EM quota that can be occupied for dialog work processes is reached. This limit is set with profile parameter ztta/roll_extension_dia.

Once the EM quota is reached, dialog work processes allocate a memory area from the PRIV memory (HEAP). If the quota for the PRIV memory (abap/heap_area_dia) is reached, the running ABAP program is terminated and an ABAP short dump is created. The consumption limits of memory (EM or heap) in SAP Memory Management is a protection mechanism in the ABAP system that is intended to prevent individual user sessions or programs from using up the entire memory.

Non-Dialog Work Process

In non-dialog work processes (such as background, update, or spool work processes), the user context is not switched, which is why these work processes are allocated PRIV memory first. PRIV memory is available to the work process until the PRIV memory quota that a non-dialog work process can allocate for a user context is reached. This quota is defined in the profile parameter abap/heap_area_nondia.

If the PRIV memory quota for non-dialog work processes is exceeded, the work process of this type allocates a memory area from the EM. If the EM quota (ztta/roll_extension_nondia) is exceeded, the running ABAP program is terminated and a short dump is written.

Key Memory Parameters

Below is the list of key SAP Memory parameters.

  • PHYS_MEMSIZE :- Specifies the size of the main memory of the host on which AS ABAP is running.
  • em/initial_size_MB :- Specifies the total size of the extended memory (EM). The value is derived from the size of the physical main memory.
  • EM/TOTAL_SIZE_MB :- Controls the total size of the EM for the implementation of shared memory segments (SHM segments).
  • em/max_size_MB :- Specifies the maximum size of the dynamically extendable EM.
  • em/global_area_MB :- Specifies the size of the global extended memory (EG).
  • abap/heap_area_dia :- This value specifies how much PRIV memory can be allocated for a user context by a single dialog work process. The aim is to limit the maximum size of user contexts so that one single user cannot occupy the entire memory available.
  • abap/heap_area_nondia :- Specifies how much PRIV memory, a non-dialog work process (background, update, the system and print processes) can allocate for a user context. The aim is to limit the maximum size of user contexts so that one single user cannot occupy the entire memory available.
  • abap/heap_area_total :- Specifies how much PRIV memory dialog and non-dialog work processes can allocate for user contexts.
  • abap/heaplimit :- This value specifies the amount of PRIV memory that, if exceeded, automatically restarts a work process after completion of the current transaction step. A bottleneck in the swap space should be prevented by using an automatic restart (as seldom as possible).
  • em/proc_max_size_MB :- Specifies the maximum amount of PROC memory all work processes together can use. The value 0 means that there is no limit to the PROC memory.
  • rdisp/wppriv_max_no :- The value specifies the maximum number of work processes that are allowed to be in PRIV mode.
  • rdisp/max_priv_time :- This parameter value specifies the maximum time spent by a work process in PRIV mode.
  • ztta/roll_extension :- Specifies how much EM can be assigned to a user session (user context). The EM quota applies both to dialog work processes and to non-dialog work processes. The current parameter value is the default value for ztta/roll_extension_dia and ztta/roll_extension_nondia. ztta/roll_extension only takes effect if its value is lower than em/initial_size_MB.

SAP Memory Management – Monitoring

The monitoring tools allow you to monitor your running ABAP system. The following tools are suitable for monitoring.

  • Memory Tune Summary (ST02) :- Displays a snapshot of memory consumption on a specific application server instance (AS instance). A snapshot of the current consumption (as a percentage of the total amount and as an absolute value in kilobytes) and of the maximum consumption of various memory types is displayed.
    • To display the memory quotas for the different work process types, choose Goto -> Current Local Data -> SAP Memory -> Quotas.
    • You can monitor the memory consumption in the internal sessions of a user. To do this, choose Goto -> Current Local Data -> SAP Memory -> Mode List. In the table, you can see how much-extended memory (EM used) and PRIV memory (HEAP) is being used in the internal sessions of the user on this AS instance.
    • You can display the current configuration in SAP Memory Management, by choosing Current Parameters on the screen or by choosing Goto -> Profile Parameters -> Current. The table shows the profile parameters and their current values.
  • Operating System Monitor (ST06) :- Here you can monitor the swapping of memory pages and the available swap space in the operating system.
  • Report RSMEMORY :- You can use the report for test purposes, and define the order of memory allocation.
  • Program sappfpar :- You can use this program to check the configuration of SAP Memory Management in an AS instance profile via OS level. The program generates a list. Under swap space requirements estimated you can see the size of the SAP shared memory (shared memory) of the PRIV memory (processes), and of the extended memory that is required for this profile. Beneath this you can see the minimum requirement of swap space (Total, minimum requirement), the maximum worst-case requirement of PRIV memory (Process local heaps, worst case), and of swap space (Total, worst case requirements).
  • CCMS Monitoring (RZ20) :- You use the Alert Monitor in the Computing Center Management System (CCMS) to monitor the entire system, including memory resources.
  • User Overview (SM04) :- In the user overview you can see all active users on a specific application server (AS instance) or across the whole system. Here you can find information about the consumption of extended segments memory (ES), extended memory (EM), and PRIV memory.
  • Work Process Overview (SM50) :- In the work process overview (transaction SM50) you can see how much memory a single work process consumes, and monitor how many work processes are running in PRIV mode. This is an indication of an increased consumption of PRIV memory.

We hope that you find the content provided helpful. Till our next article, Stay Healthy, Stay Safe, Jai Hind!

Reference

  • help.sap.com
  • SAP Notes

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

error: Content is protected !!
Exit mobile version