Skip to Content
Author's profile photo Jayashree Desai

ABAP Memory Inspectors

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.
  • You want 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.


/wp-content/uploads/2014/02/memory2_385701.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.

/wp-content/uploads/2014/02/memory4_385703.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.

/wp-content/uploads/2014/02/memory5_385704.png

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi,

      Thanks for sharing this useful tip.

      two comments:

      1. Both classic ABAP Debugger and New ABAP Debugger have also built-in memory analysis tool:

      In classic debugger, you may choose the menu option by choosing the menu option Goto -> More screens -> Memory usage.

      In new debugger, you may add the Memory Analysis tool (under Memory Management).

      You may read about the new features of the New Deubbger in New Memory Analysis Features in NetWeaver 7.0 EHP2 byStephen Pfeiffer.

      2. In the New ABAP Debugger, Development->Memory analysis->Create Memory snapshots menu isn't available anymore. You may create memory snapshots via the services of Memory Analysis tool.

      Alternatively, you can always use /hmusa (or menu System -> Utilities -> Memory Analysis -> Create Memory Snapshot).

      Author's profile photo Jayashree Desai
      Jayashree Desai
      Blog Post Author

      Hi ,

      Thanks a lot for sharing the details.

      Regards,

      Jayashree

      Author's profile photo Gaspar Zoltan Erdelyi
      Gaspar Zoltan Erdelyi

      THere is also a way to create the snapshot from ABAP code, by calling cl_abap_memory_utilities=>write_memory_consumption_file( )

      Author's profile photo Balint Szebenyi
      Balint Szebenyi

      This class was a helpful addition, thanks!