SAP专家培训之Netweaver ABAP内存管理和内存调优最佳实践

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

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

2. Use Reference to Access Memory Object

ABAP里引用的用法

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. 写时拷贝的工作原理

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

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

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

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

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

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

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

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

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

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)介绍

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程序内存消耗的尺寸计算介绍

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

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

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

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.

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

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

22. 什么是ABAP的工作进程

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

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

这道题的答案:

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 )

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 160,026评论 4 364
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,655评论 1 296
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 109,726评论 0 244
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 44,204评论 0 213
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,558评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,731评论 1 222
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,944评论 2 314
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,698评论 0 203
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,438评论 1 246
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,633评论 2 247
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,125评论 1 260
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,444评论 3 255
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,137评论 3 238
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,103评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,888评论 0 197
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,772评论 2 276
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,669评论 2 271

推荐阅读更多精彩内容

  • 执杯慢品月无色,影醉笑风聘穹苍 且把紫电擎一剑,执鞭烈马何处狂 摇尽一树花如雪,轮回怎酿情成殇 谁劫梦语作纱衣,休...
    月影007阅读 534评论 4 5
  • 独自行走在人行道上, 你总是忍不住看着脚, 右脚抬起,向前,向前 穿梭过齐平左脚尖的位置。 每次,每次脚尖着地, ...
    乱世破碎阅读 348评论 0 0
  • 一个人真正的自信,信的是什么呢? 很显然并不是那些外在的东西,如果你信的是外在的东西,那他你把外在...
    丫Yng阅读 279评论 0 0
  • 怎样让家长关注孩子的思想、纪律、学习等在校生活,我想应该是我们班主任应该我探索的目标。我探索着记录孩子的成长足迹。...
    实小无影阅读 170评论 1 2
  • 湖畔的夕阳,青草地,夜空下的十字架 彼岸,再没有罪的污染,会有多么美丽
    清风书梦阅读 165评论 0 1