Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 8800

ABAP Memory Inspectors

$
0
0

The amount of memory an ABAP program consumes depends on the amount of data being processed, which is typically stored in some type of in-memory structure (such as internal tables) that grows dynamically to accommodate the stored data. If the amount of stored data to be loaded into system memory exceeds the size of available storage area, the program terminates, possibly with the runtime errors such as SYSTEM_NO_ROLL or TSV_TNEW_PAGE_ALLOC_FAILED.

 

  Because these errors can arise for a variety of reasons, the root cause may not be immediately obvious .For example, the runtime error TSV_TNEW_PAGE_ALLOC_FAILED occurs when the system can’t increase the size of an internal table due to insufficient available memory. However, this internal table might not be the reason why memory is exhausted. What you need in this situation is a tool to help you determine the real reason that the application has run out of memory.

 

The ABAP Memory Inspector provides you with an overview of dynamically allocated data (that is, all dynamic in-memory structures) at a particular time, which can be very helpful for diagnosing memory consumption problems, as well as a specialized transaction for analyzing this data.

 

Using the ABAP Memory Inspector

 

Analyzing the memory consumption of an application typically consists of two types of scenarios:

 

  • You’re interested in the current memory consumption of a running program in order to check if it is unexpectedly high.
  • Youwant to compare the memory consumption of a program at different times in order to find out if it increases in an undesirable way and to identify which memory objects contribute to the increase.

 

 

Creating the Memory snapshots

 

There are several ways to create a memory snapshot:

  • When debugging an application, select Development->Memory analysis->Create Memory snapshots from the ABAP debugger menu bar .A completion message indicates when the file is ready.
  • Enter the command /hmusa in the command field on any SAPGUI screen –you don’t need to be in the debugger .When the file is ready, you will see the same completion message shown for the previous option.

 

Analyzing and Comparing Memory Snapshots

 

The ABAP Memory Inspector provides a dedicated transaction for displaying the content of stored memory snapshots.

 

You start this transaction via S_MEMORY_INSPECTOR, or Memory analysis ->Compare Memory snapshots from the menu bar.

 

 

For Example:

Lets say you want to analyze the memory consumption of some program (demo program : ZTEST_MEMORY)

Run the report ZTEST_INDEX


Memory.png

 

You will get the output as below.


Memory1.png

Now enter /hmusa in the command field.


memory2.png

Message will be displayed at the bottom indicating that memory snapshot is created.


Memory3.png

To the view the memory snapshot go to the transaction S_MEMORY_INSPECTOR.

 

memory4.png

Double-click on an entry in the list to open a screenshot and display its contents in the lower part of the screen. You can have up to two snapshots open at one time. Opening a third snapshot automatically closes one of the others based on the difference in creation time. The first opened snapshot is referred to as (t_0);second as (t_1) .To select an open snapshot for display ,use the (t_0) and (t_1) buttons in the application at the top of the screen, or use the Memory Snapshot dropdown list located above the display tree in the lower part of screen.

 

 

  • Overview (the default view) shows the objects in memory ,separated by type ( programs, classes ,table bodies ,strings)

· Ranked List displays the contents of a memory snapshot sorted by the memory consumption of the contained memory objects. Type-like entities such as classes and types of anonymous memory objects are not included in this list, only their instances are. Furthermore, the ranking list does not include any programs. For each memory object, the list shows the values of bound allocated, bound used, referenced allocated, and referenced used memory. If a memory object is part of an object cycle (SCC), the total memory of the object cycle is displayed in the columns SCC (Allocated) and SCC (Used) (SCC stands for strongly connected component; see Memory Use). Otherwise, the value is zero. Only objects that can reference other memory objects can be part of an object cycle (that is, internal tables and class instances).

  • Ranking List by Type is similar to the ranking list. However, the former displays the classes and types of anonymous data objects at the top level and not the class instances and anonymous data objects themselves. Therefore, you can see the memory consumption of an entire class, including all its instances, in relation to the total memory consumption, for example. As in the overview, you can display the instances for a class below this class and the data objects themselves below the types of anonymous data objects.
  • The view Object Cycles (SCC) displays all non-trivial object cycles (that is, all cycles that contain more than one object). This view shows the number of contained memory objects and the occupied memory for each cycle.  Below the cycles, you can display the contained objects. When you create a memory snapshot, object cycles are recognized dynamically and numbered consecutively. This description is not stable. Therefore, you cannot compare object cycles from two different memory snapshots.
  • The System Memory view displays the memory consumption of internal services within the ABAP runtime environment. The actions of ABAP programmers have no immediate influence on these values.

Comparing the Memory Snapshots

You can compare two existing memory snapshots by forming differences.

A comparison is carried out by:

  • Choosing Display Difference in the Initial Screen of the Memory Inspector
  • Specifying (t_1 - t_0) in the Memory Snapshot input field in the display area of the Memory Inspector
  • Choosing the function Memory Analysis ® Compare Memory Snapshots in the ABAP Debugger

 

To be able to compare memory snapshots, they must have been created within the same internal session.

 

In the difference display, the memory objects are displayed in three categories.

First, the system displays any new memory objects. These are indicated by a plus sign before the object name and displayed in red indicating memory increase.

The system next displays the memory objects whose memory consumption has changes. They are displayed in black. Only those values that have changed are highlighted in color. The objects are sorted by their change in memory value .This could indicate either an increase or decrease.

Finally, the system displays the memory objects that still existed at the time t_0 but not at the time t_1. They are in blue and indicated by a minus sign before the object name, indicating memory decrease. Again, the objects are sorted by their absolute values.

The difference display does not include memory objects that exist both for t_0 and for t_1 and have the same memory values.

 

memory5.png


Viewing all articles
Browse latest Browse all 8800

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>