ImageVerifierCode 换一换
格式:DOCX , 页数:12 ,大小:62.95KB ,
资源ID:5771375      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5771375.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Detecting Memory Leak OnAIX.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Detecting Memory Leak OnAIX.docx

1、Detecting Memory Leak On AIXMethods for Identifying Memory Leaks in AIX SystemsBy Barry J. Saad and Harold R. LeeApplication memory leaks can be difficult to detect and on modern multi-tasking systems where many applications are running, it can be even more difficult to identify the offending proces

2、s(es).This paper will explore the reasons for memory leaks, and using the AIX system performance tools, provide a methodology for identifying them to the process level. This paper will consist of four major parts: (1) definition and causes for a memory leak on a system, (2) examining a process heap

3、using svmon and ps, (3) a method for detecting memory leaks on a system, (4) a method for identifying individual processes which have memory leaks.The Causes for Memory LeaksThe Jargon File version 4.2.0 defines a memory leak as:memory leakn. An error in a programs dynamic-storeallocation logic that

4、 causes it to fail to reclaim discarded memory,leading to eventual collapse due to memory exhaustion. These problems were severe on older machines with small, fixed-size address spaces, and special leak detection tools were commonly written to root them out. With the advent of virtual memory, it is

5、unfortunately easier to be sloppy about wasting a bit of memory (although when you run out of memory on a VM machine, it means youve got a _real_ leak!).Memory is allocated to a processes heap by using the malloc() C library call or in C+ when a class is instantiated by calling a “constructor” which

6、 will “set up” the class by allocating the required memory for the class and initializing the members. When the memory is no longer required by the process, it is released for reuse by the free() C library system call or in C+ when the class is “torn down” by calling a “destructor” which will releas

7、e the memory for reuse. When a process terminates, all of the programs dynamic-store which is also called the processes heap and stack are returned to operating system for reallocation to other processes. Memory leaks occur when memory that is allocated to the heap is not released by the process and

8、 the heap will continue to grow. Over time, the process will either allocate all of the memory and fill its address space which may cause abnormal termination of the process or it will use up the virtual memory and cause the kernel to take protective measures to preserve the integrity of the operati

9、ng system by killing processes to relieve the virtual memory demands. Unfortunately, memory leaks are usually caused by long running processes and the algorithm which the kernel uses to reduce virtual memory demands is to start killing processes based on the “youngest” process (most recently created

10、) and working toward the “oldest”. This can have the effect of many processes being “killed” before the offending process is dealt with. Due to the complexity of programs and the levels of memory allocation and deallocation abstraction in object oriented programs, memory leaks are sometimes very dif

11、ficult if not impossible to completely eliminate. One approach to this problem is to limit the lifespan of a program where the program is terminated before any potential memory leaks are allowed to grow enough to become a problem. The Apache web server is an example of this approach. When the Apache

12、 server is started, a parent process started which allocates very little memory and does very little work. The parents job is to initially spawn some number of child server process set by the StartServers directive in the configuration file, and then to try to maintain the number of child server pro

13、cess between two levels either by creating or killing additional processes. This window is set by the MaxSpareServers and MinSpareServers directives in the startup configuration file. MaxRequestsPerChild directiveThe MaxRequestsPerChild directive sets the limit on the number of requests that an indi

14、vidual child server process will handle. After MaxRequestsPerChild requests, the child process will die. If MaxRequestsPerChild is 0, then the process will never expire.Setting MaxRequestsPerChild to a non-zero limit has two beneficial effects: it limits the amount of memory that process can consume

15、 by (accidental) memory leakage; by giving processes a finite lifetime, it helps reduce the number of processes when the server load reduces. Each child server processes will keep track of the number of requests which it will handle and after this number has been reached, the process will die and re

16、turn all of the virtual memory to the kernel heap for reallocation. The following snippet is from the configuration file instruction page. Notice the reason given for limiting the lifetime of the child:Not all applications have the flexibility of Apache to deal with potential leaks. Another strategy

17、 is for companies to schedule regular intervals for the applications to be recycled. This involves shutting down the applications and restarting them. While some reboot the entire system, this is not necessary unless there are mitigating circumstances such as a maintenance patch or a reboot specific

18、 tuning change (e.g. changing the asynchronous subsystem parameters).Another form of process memory leakage is called “heap fragmentation”. Heap fragmentation, which is the bane of operating system design, is something developers have had to contend with since the beginning. A google search on “heap

19、 fragmentation” will return over 64,000 hits illustrating the magnitude of this issue. Heap fragmentation is when available memory is broken into small, non-contiguous blocks. When this occurs, memory allocation can fail even though there is enough memory in the heap to satisfy the request, because

20、no one block of memory is large enough to satisfy the allocation request.For applications that have a low memory usage, the standard heap is adequate; allocations will not fail due to heap fragmentation. However, if the application allocates memory frequently and uses a variety of allocation sizes,

21、memory allocation can fail due to heap fragmentation.Heap fragmentation is caused by numerous subsequent malloc()s and free()s on the process heap with widely varying sizes. This cause “holes” to form in the contiguous heap and unless a malloc() is small enough to use the space within a “hole” the p

22、rocess heap must grow to satisfy the request. One strategy for dealing with heap fragmentation is to employ a technique called “Garbage Collection”. When a request cannot be satisfied from the heap due to fragmentation, the garbage collection routine is called which moves all of the “holes” to the e

23、nd of the heap, making all of the space available at the end of the heap. This garbage collection is analogous to defragmenting a hard drive, which moves all of the unused space to the end. Some of the early operating systems employed garbage collection techniques however this causes very erratic pe

24、rformance from the system since all activity had to stop while the memory was re arranged. The Java virtual machine (JVM), which is a “guest” operating system, currently uses this method with similar results. Garbage collection is not used on most operating systems today due in part to the erratic p

25、erformance it produces.Another strategy which some programs use to eliminate this is to manage the heap internally through the use of pointers. When the program starts there is a single memory allocation call to obtain the heap and then the program itself will allocate portions out of it to satisfy

26、the internal requests. Most data base programs like Oracle and DB2 use this method of internal memory management.Operating system developers continue to work on more efficient memory allocation algorithms and incorporate them into the kernels to reduce this issue to one on minimum impact. The Window

27、s developers have introduced a heap manager called the “Low Fragmentation Heap” (LFH) which places the holes in a Cartesian btree structure similar to the AIX 4.2 5.2 malloc routine known as the “Yorktown malloc” since it was developed by the Yorktown research facility. A new malloc called the “wats

28、on malloc” is available on AIX 5.3. The Watson malloc which is cache based and uses a simplified rbtree (red-black tree) structure increases malloc performance as well as reducing heap fragmentation. The new malloc() is optimized for large multi-threaded applications and time will tell how much more

29、 efficient it is. For more information on this malloc refer to the following link: Refer to the section - Understanding the Watson Allocation PolicyFrom a system administration perspective, heap fragmentation is dealt with the same manner as a memory leak. The applications must be quiesced and resta

30、rted.Examining A Process Heap Using svmon and psFor an overview of the virtual memory management at a process level, refer to the following articles and info pages:http:/w3-Article Understanding Virtual Memory ManagementAlso refer to the man or info page on the svmon and ps commandsThe processes vir

31、tual memory footprint consists of three separate items. The actual (1) heap and the (2) process stack which is addressed by (esid) register “2”, and the (3)shared library data which is addressed by register “f”. The loader segment “d” is shared by all processes and is ignored. # svmon -nrP 262188- P

32、id Command Inuse Pin Pgsp Virtual 64-bit Mthrd LPage 262188 mamain 65980 4784 0 65977 N N N Vsid Esid Type Description LPage Inuse Pin Pgsp Virtual 23e9 2 work process private - 53263 3 0 53263 Addr Range: 0.53247 : 65314.65535 1f09d d work loader segment - 3508 0 0 3508 Addr Range: 0.8684 63ad f work shared library data -

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1