MORE INFORMATION
When you access performance data information, the
Performance Library (PerfLib), which is part of the Advapi32.dll file, calls
the
Collect functions of all performance services on the system. These
functions are executed by a thread in your process, and any performance service
memory leaks will show up in the context of your process.
It can be
difficult to debug this kind of memory leak because the leak does not originate
in your program; it originates in a performance DLL file. This article
describes MemLeakTest.exe, which is a tool that you can use to determine which
performance services on the system may be leaking memory.
The following
file is available for download from the Microsoft Download
Center:
Release Date: June 20,
2002
For additional information about how to download Microsoft
Support files, click the following article number to view the article in the
Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
You can also download the C++ source code and build the
tool yourself.
The following file is available for download from the Microsoft
Download Center:
Release Date: June 20,
2002
For additional information about how to download Microsoft
Support files, click the following article number to view the article in the
Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most
current virus-detection software that was available on the date that the file
was posted. The file is stored on security-enhanced servers that help to
prevent any unauthorized changes to the file.
Performing the Memory Leak Test
After you download the tool, follow these steps to perform the
memory leak test:
- Determine which performance services are installed on your
system. To obtain a list, call MemLeakTest.exe with no parameters.
This tool also shows the DLL file
size and time stamp. - Call MemLeakTest.exe ALL Global.
- The first parameter (MemLeakTest.exe) refers to the set of performance services.
- ALL indicates to test all of the performance services.
- The second parameter (Global) is the list of objects to test.
The tool loads each of the Performance Extension DLLs in a
separate MemLeakTest.exe process and then monitors for the Private Bytes memory growth by calling the collect procedure directly every 100
milliseconds. The Private Bytes information is logged to a file for each performance service in a
.txt file every 1 minute. Every performance service will have a corresponding
.txt file (for example, Tcpip.txt for TCP/IP Performance Service) that is
created in the current working directory.
As long as the
MemLeakTest.exe tool is running, the Private Bytes information is logged to the respective .txt files continuously
in a loop until you stop the test by pressing any key at the command prompt.
After you run the tool for some time, you can analyze the .txt files for any
memory growth. - Examine each of the log files to see whether any of the
DLLs are leaking memory.
- If none of the log files indicates a memory leak, try
calling MemLeakTest.exe ALL ALL.
This adds objects individually to the query instead of
using the Global object. Rarely does this test uncover leaks that the ALL Global test misses, and it makes sense to run it only if your software
queries objects individually.
Options When Running MemLeakTest.exe
You can use the following options when you run MemLeakTest.exe:
- Run MemLeakTest.exe /?. This displays the various command line options.
- Run MemLeakTest.exe without any command-line arguments. This displays the performance
services that are installed on the system, including file size and date/time on
the Performance Extension DLL.
- Run MemLeakTest.exe ALL Global.
- Run MemLeakTest.exe ALL ALL. This is the same as MemLeakTest.exe ALL Global, except that the Collect procedure of each performance service is called with all valid
object indexes on the system.
- Run MemLeakTest.exe Tcpip Global. This is the same as either MemLeakTest.exe ALL Global or MemLeakTest.exe ALL ALL, except that the Collect procedure is called only for the specified performance service
name with the specified value name.
The ValueName parameter can be any of the following:
- Global
- Object indexes that are enclosed in quotation marks,
for example, "2 4".
- ALL, to indicate all object indexes.
After you run the MemLeakTest.exe tool for a while to collect
the .txt files, and then you stop the tests by pressing any key, you can
analyze the .txt files to determine which performance services show a steady
Private Bytes memory growth, as reported in the .txt file. If one or more
performance services show memory growth in the corresponding .txt file, contact
the vendor responsible for the Performance Extension DLL, and then report the
problem to determine the memory growth at the code level.
This
article contains the following downloadable files:
|
MemLeakTest.exe | 56 KB |
MemLeakTestCode.exe | 27 KB |