贵阳大唐发电集团:windows操作系统调优 2 - 数据库相关 - 7点测试网

来源:百度文库 编辑:九乡新闻网 时间:2024/05/01 14:43:48

windows操作系统调优 2

发布: 2010-2-23 14:42 | 作者: sodjiang | 来源: 7点测试网

首先分享一篇文章的地址.
http://www.360doc.com/content/08/0630/17/51673_1384252.shtml
介绍了有关内存计数器的基本概念,总结的相当好!尽管有不正确的地方
先介绍几个很重要的性能计数器
什么是内存池?通常,我们都采用NEW或者malloc动态申请内存。一般来说,少量的操作不会造成什么影响,但是,如果我们频繁去申请内存块,会造成效率上的损失,更有甚者,我造成内存碎片的存在,从而影响系统的效率(所有程序都可能受到影响),一种最常见的解决办法就是一次性申请一个大点的内存块,每次需要的时候就"切"一块下来用,如果该内存块不够才去申请内存。这种技术叫做内存池。一般来说,内存池对于每次申请固定大小的内存的应用(比较频繁)会比较有好处。
而换页池和非换页池对应的是内存空间,非换页池可保证总是驻留在物理内存中而不会被交换出去,比如负责paging的代码,如果这段代码也可以被交换出去的话,那虚拟内存技术就不能实现了。重点关注下面的计数器
Memory \ Pool Nonpaged Bytes
Memory \ Pool Nonpaged Allocs
Memory \ Pool paged Allocs
Memory \ Pool paged Bytes
这几个计数器前面都有描述,下面看我们本节的重点:内存泄露
1 内存泄露的概念
  A memory leak occurs when applications allocate memory for use but do not free allocated memory when finished. As a result, available memory is used up over time, often causing the system to stop functioning properly.
2 内存泄露出现的症状
A gradually worsening response time
The appearance of an error message, shown in Figure 6.7, indicating that the system is low on virtual memory. (Another message box might precede this, indicating that virtual memory has been exceeded and that the system has increased the paging file size automatically.)
3检测某个应用程序是否出现内存泄露应观察的计数器
Memory\Available Bytes reports available bytes; its value tends to fall during a memory leak.

Memory\Committed Bytes reports the private bytes committed to processes; its value tends to rise during a memory leak.

Process( process_name )\Private Bytes reports bytes allocated exclusively for a specific process; its value tends to rise for a leaking process.

Process( process_name )\Working Set reports the shared and private bytes allocated to a process; its value tends to rise for a leaking process.

Process( process_name )\Page Faults/sec reports the total number of faults (hard and soft faults) caused by a process; its value tends to rise for a leaking process.

Process( process_name )\Page File Bytes reports the size of the paging file; its value tends to rise during a memory leak.

Process( process_name )\Handle Count reports the number of handles that an application opened for objects it creates. Handles are used by programs to identify resources they must access. The value of this counter tends to rise during a memory leak; however, you cannot rule out a leak simply because this counter's value is stable.
监测这些计数器时,我们应注意两点
1〉 要有持续时间,最好几天
2 〉就在本地机器上监控
4 Memory Leaks and the Nonpaged Pool
Although any leak is serious, memory leaks are of particular concern when they involve the nonpaged pool. Many system services allocate memory from the nonpaged pool because they need to reference it when processing an interrupt and cannot take a page fault at that time. To identify whether or not a leak affects the nonpaged pool, include the following counters in your monitoring:
Memory \ Pool Nonpaged Bytes
Memory \ Pool Nonpaged Allocs
Process( process_name)\ Pool Nonpaged Bytes

To use System Monitor to monitor the nonpaged pool for leaks, follow these steps:
1〉Record the size of the nonpaged pool when the system starts. Then log the Memory and Process objects for several days; a 10-minute update interval is sufficient.
2〉Review the log for changes in size of the nonpaged pool. You should be able to associate any increases in the size of the pool, as indicated by Memory \ Pool Nonpaged Bytes, with the start of a process, as indicated by Process \ % Processor Time. Also look at individual Process object counters such as Process\Handle Count, Process\Private Bytes, Process\Nonpaged Pool Bytes, Process\Paged Pool Bytes, and Process\Threads. During a memory leak, you might also see rising values for these counters. When processes are stopped, you should see a decrease in pool size. Any growth in the nonpaged pool is considered abnormal, and you need to distinguish which process is causing the change in pool size. You might also want to monitor the number of active threads before and after running the process (use the Performance tab in Task Manager or the Objects \ Threads or Process(_Total) \ Thread Count counters). A process that is leaking memory might be creating a large number of threads; these appear when the process starts and disappear when the process stops.
3Watch the value of Memory \ Pool Nonpaged Bytes for an increase of ten percent or more from its value at system startup to see if a serious leak is developing.
最后有个工具要提下:
Process Monitor (pmon.exe)
Provides total and per process values for nonpaged and paged pool memory. Also monitors the committed memory values shown in the Pmon display for increases; the process with the leak should have an increasing value reported under Commit Charge.
可以到微软网站上去下,最好也把wingdb也下了,这样可以直接定位到具体的代码。