To study the copy-on-write mechanism of tables in SAP ABAP, ABAP Memory Inspector is an essential tool.
The ABAP Memory Inspector can report the memory used by internal sessions running ABAP programs.
This tool can provide data in the following two dimensions:
- Directly attributable to the memory consumption of the ABAP application. This includes memory in the static and dynamic memory objects of the ABAP program, as well as memory used by programs on the ABAP stack.
- Memory allocation for the entire internal session against the host operating system. This includes ABAP memory consumption and a relatively small amount of memory consumed by the ABAP runtime and internal session management.
The Memory Inspector always runs the ABAP garbage collector before taking a memory snapshot, so that dead
memory objects don't affect metrics of memory consumption data.
In general, and especially since the overhead of running the internal session itself is small, we generally focus the memory analysis problem on the memory consumption of the ABAP application itself. After all, as developers, we can in any case only affect the memory consumption of the ABAP program, not the memory consumption of the runtime system.
Dynamic and Static Memory Objects
Among the types of ABAP memory objects, the most problematic are dynamic memory objects. The so-called dynamic memory objects are those objects whose size can change as the program runs. They include the following types of ABAP entities:
- ABAP inner table (or rather, the row in the inner table, its body)
- string
- Class objects (objects created by the CREATE OBJECT statement)
- Anonymous data objects (objects created by the CREATE DATA statement)
- boxed Component
Variables used to access dynamic memory objects contain references to internal memory structures that hold data for dynamic memory objects. Therefore, the variables of dynamic memory objects are collectively called 引用变量
.
In ABAP, a referenced program entity is called a "deep Component", that is, a component whose content must be accessed by evaluating the reference.
By contrast, static memory objects (static variables, in the Memory Inspector display) are those objects whose size is set by the data type declaration at design time. The memory occupied by such variables in the program does not change unless the program code itself changes. Static variables are also called flat variable
or flat Component
in ABAP parlance.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。