欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践 SAPSAP成都研究院ABAP培训JerryWang 

程序员文章站 2022-06-10 22:28:49
...

培训者:SAP成都研究院开发人员Jerry Wang

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

1. Understanding Memory Objects in ABAP

Note1: DATA itab WITH HEADER LINE for processing individual table rows have short forms that implicitly use the header line as work area. These short forms are allowed only outside of ABAP Objects.

/SF0A0001/ANONYMOUS

495142

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

2. Use Reference to Access Memory Object

ABAP里引用的用法

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

3. ABAP和很多其他语言一样,支持写时拷贝:

As internal tables and strings can become very large, the copy operation may be quite time-consuming. On the other hand, the copy operation is only necessary if a modification is made via one of the references, which is NOT always the case.

For this reason, ABAP runtime delays the copy operation until a modification is actually made. These object types (internal tables and strings) keep track of the number of references that point to them, which is referred to as “reference counting.”

4. 写时拷贝的工作原理

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

5. ABAP的内存管理之内存清理

内存释放关键字CLEAR,REFRESH和FREE的区别:

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

6. ABAP引用类型的内存分配

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

7. ABAP字符串(String)类型的内存分配

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

8. ABAP内存垃圾回收器的工作原理

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

9. ABAP内存垃圾回收的实现算法

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

10. ABAP垃圾回收机制的触发时机

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

11. ABAP垃圾回收的手动触发,请谨慎使用

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

12. 更多关于引用类型的变量在ABAP垃圾回收算法中的影响

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

13. ABAP bound memory的含义

the sum of the size of the memory object and the bound memory of all DIRECT children that are table bodies or strings with a reference count of one.

Upon deleting the memory object, the bound memory is the minimum amount of memory that is released, and the referenced memory is the maximum amount that can be released. Therefore, the amount of memory that is actually released is somewhere between these two values.

14. ABAP内存预分配算法(preallocation mechanism)介绍

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

15. ABAP已分配内存和已使用内存的区别

For internal tables and strings, ABAP runtime environment uses a preallocation mechanism that automatically reserves some EXTRA storage when the memory object is created to allow for potential growth.

It avoids many allocation and deallocation operations. Otherwise, ABAP runtime environment would have to allocate new storage every time the memory object grows.

Due to this preallocation mechanism, both internal tables and strings also have “allocated memory” and “used memory” values as memory sizes.

Allocated memory is the amount of memory that is set aside for the memory object. Used memory is the current size of the memory object used by the application.

For class objects and anonymous data objects, used memory and allocated memory are the same. Because their size is fixed, they don’t require additional space to accommodate growth.

16. ABAP程序内存消耗的尺寸计算介绍

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

17. 什么是ABAP内存分配中的SCC - strongly connected component - 强连通组件

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 
 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

18. 有用的ABAP内存分析和调优工具,事务码S_MEMORY_INSPECTOR

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

19. 具体例子,您知道下面这段代码,新生成的引用类型的变量,内存是从哪里分配的?堆?不完全对。

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 
 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

Logging on to an application server opens a user session. A user session is assigned its own memory area of the SAP memory, in which SPA/GPA parameters can be stored.

For every user session , a main session ( external session ) can be opened. Each main session is assigned its own memory area of ABAP memory ( EXPORT --- IMPORT ) rdisp/max_alt_modes

Each call of an ABAP program creates a new internal session, in which the called program is loaded.

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

20. 什么是ABAP程序的PXA - Program Execution Area

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

21. ABAP程序的用户上下文 - User Context

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

22. 什么是ABAP的工作进程

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

23. ABAP工作进程的内存虚拟地址空间和物理地址空间的映射

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

Roll Area:

Memory area with a set (configurable) size that belongs to a work process.

For technical reasons, the roll area is always the first memory available to use for a work process. Only afterwards can extended memory be requested.

When the context of a work process changes, the data is copied from the roll area to a common resource known as the roll file. To prevent repeated copying, another roll buffer is located in between, which is part of the shared memory

Paging area:

Allocation of memory for the current internal session by transferring pages out of memory, similarly to operating system paging. SAP's memory management concept currently limits SAP Paging to cases where the ABAP commands EXTRACT and EXPORT... TO MEMORY... are used.

Private memory:

If the extended memory is fully occupied, or the limit for the work process has been exceeded, private memory is assigned to the work process. This is known as private memory because it is specific to the process, and the user context can no longer be processed by a different work process (PRIV mode).

ABAP扩展内存 - extended memory

User context is stored in the extended memory (EM) to enable fast context change . Depending on the operating system, how SAP implements EM addressing/mapping is different.

When the context is changed, the user context is not copied as with the roll area. Instead it is allocated to alternating work processes by mapping operations which results in a faster context change because less data is copied and mapping an extended area is not work-intensive. The result is low CPU usage and shorter access times.

SAP dispatcher is responsible for the following principle tasks:

1. Initialization, reading profile parameters, starting work processes and logging on to the message server

2. Evenly distributing the transaction load across work processes

3. Connecting to the GUI layer

4. Organizing communication processes

这道题的答案:

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang 

The roll area consists of two segments. The first segment, which can be set with the parameter ztta/roll_first, is assigned to the work process first as memory. If this is used up, the work process has more memory assigned to it. The amount of memory is determined by the difference between the ztta/roll_area and ztta/roll_first parameters.

正确答案,不能一概而论,有三种情况。

情况1:

Roll area: if ( roll_current_area + request size <= roll_area )

情况2:

Extended memory: if ( roll_current_area + request size > roll_area ) AND ( extend memory is not full )

情况3:

Private memory: if ( roll_current_area + request size > roll_area ) AND ( extend memory is full )

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

 
SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践
            
    
    
        SAPSAP成都研究院ABAP培训JerryWang