While dealing with our SAP systems daily in any form like monitoring , troubleshooting , performing any activity we encounter some runtime errors.Many a times due to these runtime errors we are faced with consequences where our session (user session ) is terminated. There are multiple types of runtime errors that we encounter. Some may occur due to RFC related errors , some due to memory configuration (mis-configuration) and many more others.
Here in this blog we will focus on the runtime errors occurring due to memory related issues.
To have a look at how SAP memory management works please refer this below link:
What is Memory Management ? Is there a definition at all ?
The most basic definition that we can associate with memory management is :
An application runs in a work process where an ABAP program is normally executed. The process requires memory to do this, which is allocated to the process by the memory management system. The order in which the work process is assigned the memory type depends on the work process type, either dialog or non-dialog (see SAP Memory Types), and the underlying operating system.
Regarding the memory management frequently used terminologies please see the link here :
How many types of memory exists ?
The memory management system assigns memory to a work process. The different memory types are ( the major ones and most commonly used ) are :
Private memory (heap memory)
The sequence of allocation depends on the type of work process and the configuration.The user context area that allows direct access can be extended as required when the size of the user context increases.
TIP : With SAP NW 7.4 ‘ roll area ‘ has been integrated with the extended memory.Part of the former roll memory is allocated out of EM while the other parts of the former roll memory is allocated out of EG (i.e. out of the EG area which is sized by profile parameter em/global_area_MB). Details can be found in SAP Note #2085980.To know how the memory management changed from NW 7.x and NW 7.4 X please refer to this SAP note #2148571 – Explanation for higher Extended Memory (EM) and Extended Global Memory (EG) consumption after upgrade to SAP Kernel 7.4x
How do I monitor my Memory ?
Monitoring the Memory Management System, to access the complete information please check the link here
You should monitor the SAP system during operation to check that memory management has the necessary resources, and that frequent paging at operating system level does not slow down the system or cause any bottlenecks.
The following options are used for monitoring the memory usage :
1. Tune Summary (transaction ST02)
2. Transaction ST06 for monitoring the available swap space in the host system
3. CCMS Alert Monitor (transaction RZ20)
Please follow the tutorial presented here for checking
4. Overview of Users (transaction SM04)
5. Overview of Work Processes (transaction SM50)
What about the issues/errors that we face during daily work ?
Memory run-time errors
I will list down here some common memory related errors and how to troubleshoot them.
Extended memory related errors
In case of runtime errors related to extended memory the most common form of error entries are as below , These errors may means that the program tries to allocate Extended Global Memory and due to the shortage it fails.
Some common runtime errors are : LOAD_NO_ROLL,ERROR-SESSION-ATTACH_ERROR,TSV_TNEW_BLOCKS_NO_ROLL_MEMORY,SYSTEM_NO_ROLL,STACK_STATE_NO_ROLL_MEMORY,TSV_TABH_POOL_NO_ROLL_MEMORY,
RESIZE_EM_ALLOC_ERROR , SPOOL_INTERNAL_ERROR , HTTP_NO_MEMORY ,ERROR: New session was refused due to memory bottleneck (termination: ABORT_MESSAGE_STATE)
** Set A
X *** ERROR => EgAlloc: MmxMalloc failed (9). see also file ‘eg_oom_mm.dump‘ [egxx.c 607]
X *** ERROR => EmIAllocMmResourceEg: EgAlloc(445360) failed 5 [emxx.c 4249]
In SM21 there might be entries as :
10:01:01 DIA 006 711 2123 R2 B No memory for astc
10:01:01 DIA 006 711 2123 R2 B No memory for stat
** Set B
In case of spool
S *** ERROR => no more memory for open spool handle [rspoooh.c 301]
** Set C
X *** ERROR => EgAlloc: out of memory, check em/global_area_MB and eg_oom_mm.dump file for memory allocations. [egxx.c 628]
In case of the above entries the important transactions that need to be checked are ST02.
Check in the field of ‘extended memory’ to identify the usage of the EM.
If the value MaxUse has reached the sum of (In Mem and On Disk) then the issue is that your extended memory is exhausted.
Please see the SAP notes when you face above mentioned errors ( Set A , B , C) :
#2152126 – EgAlloc: MmxMalloc failed errors followed by ST22 dumps, SM21 errors or additional sympthoms
#2148571 – Explanation for higher Extended Memory (EM) and Extended Global Memory (EG) consumption after upgrade to SAP Kernel 7.4x
#2085980 – New features in memory management as of Kernel Release 7.40
#1514752 – Extended Global Memory configuration
Though the list is small but you will find most of the information helpful to be able to resolve the issue related to extended memory (EM)/extended global memory (EG)
Errors related to Heap area
Firstly we will look at what heap memory (Private memory) is defined as:
Heap memory is a local memory assigned for the Work process in SAP. Heap Memory Contains user contexts, for example, when extended memory is full, its allocated and released on demand. Heap memory allocated by one work process is not accessible to any other work process.
If the value of abap/heaplimit has been reached, the work process is restarted after the dialog step has ended. If the consumption of heap memory exceeds the quota abap/heap_area_(non)dia, the user context being executed at this time is cancelled before it can be completed.You can use this quota to prevent one single dialog work process (user context) from filling the entire heap memory of the application server.
There are few parameters which needed to be understood here:
Limits the amount of heap memory that the ABAP runtime of all work processes of the instance (all dialog and non-dialog work processes together) can allocate;
If the ABAP runtime of a work process allocates more memory than what is specified at this parameter, the work process activates an “auto-restart” flag. When this flag is set, the work process will restart after the execution of the current task. For as long as the data in the heap memory is needed, the work process will not restart. This is a safe mechanism to trigger the restart of the work process. The restart is required so the heap memory of the work process can be released back to the OS. It is not recommended to change the value of this parameter, but to use its default value.
There is a important part of memory that is PROC memory , this is defined as :
PROC memory is used for data that is not bound to a specific user context, for example temporary, heap buffer areas. Unlike with PRIV memory, allocation of PROC memory does not lead to an exclusive reservation of the process for a specific user context.
Common problems : Due to exhaustion of heap memory the common problems that can occur are : TSV_TNEW_PAGE_ALLOC_FAILED, work process in PRIV mode , TSV_TNEW_OCCURS_NO_ROLL_MEMORY ,SYSTEM_NO_ROLL or SYSTEM_NO_MEMORY.
To troubleshoot the issues related to heap memory exhaustion we need to check the related work process trace files in dev_w*.
Common entries would be as:
–> for class Non-dia
SelMemClass: heap quota (NONDIA) exceeded 4294967296 4295043872
–> for class Dia
SelMemClass: heap quota (DIA) exceeded 4294967296 4295043872
Based on the entries you need to tune the parameters : abap/heap_area_dia / abap/heap_area_nondia.
To solve the issue the most handy notes are :
#2180736 – TSV_TNEW_PAGE_ALLOC_FAILED
Some helpful SAP wiki links are written which explain the concepts really well.
TIP: There is a very comprehensive SAP wiki written about the memory management , please see the wiki here
Fell free to let me know in case any queries.
PS: By no means this list is complete , feel free to let me know what all can be added more.