Memory Leak Detector
Last Updated: December 3, 2010
The Memory Leak Detector feature is a tool that can be used to detect memory leaks on a router that is running Cisco IOS software. The Memory Leak Detector feature is capable of finding leaks in all memory pools, packet buffers, and chunks.
Your software release may not support all the features documented in this module. For the latest feature information and caveats, see the release notes for your platform and software release. To find information about the features documented in this module, and to see a list of the releases in which each feature is supported, see the "Feature Information for Memory Leak Detector" section.
Use Cisco Feature Navigator to find information about platform support and Cisco software image support. To access Cisco Feature Navigator, go to http://www.cisco.com/go/cfn. An account on Cisco.com is not required.
Contents
•
Prerequisites for Memory Leak Detector
•
Restrictions for Memory Leak Detector
•
Information About Memory Leak Detector
•
How to Use Memory Leak Detector
•
Examples for Memory Leak Detector
•
Additional References
•
Feature Information for Memory Leak Detector
Prerequisites for Memory Leak Detector
•
You should have at least a basic familiarity with the Cisco IOS environment and the command-line interface.
•
You should have at least a minimal configuration running on your system.
Restrictions for Memory Leak Detector
•
You must have your network up and running, with Cisco IOS Release 12.2 or a later release installed.
•
Some of the Cisco IOS configuration commands are only available on certain router platforms, and the command syntax may vary on different platforms.
Information About Memory Leak Detector
•
Memory Leaks
•
Memory Leak Detection
Memory Leaks
Memory leaks are static or dynamic allocations of memory that do not serve any useful purpose. Although technology is available for detection of leaks among statically allocated memory, in this document the focus is on memory allocations that are made dynamically.
Memory Leak Detection
From the detection point of view, leaks among the dynamically allocated memory blocks can be classified into the following three types:
•
Type 1 leaks have no references. These blocks of memory can not be accessed.
•
Type 2 leaks are part of one or more cycles of allocations but none of the blocks in these cycles is accessible from outside of the cycles. Blocks within each cycle have references to other elements in the cycle(s). An example of a Type 2 leak is a circular list that is not needed anymore. Though individual elements are reachable, the circular list is not reachable.
•
Type 3 leaks are accessible or reachable but are not needed, for example, elements in data structures that are not needed anymore. A subclass of Type 3 leaks are those where allocations are made but never written to. You can look for these subclass leaks using the show memory debug reference unused command.
The Memory Leak Detector feature provides the technology to detect Type 1 and Type 2 memory leaks.
The Memory Leak Detector feature works in the following two modes:
•
Normal mode—Where memory leak detector uses memory to speed up its operations.
•
Low memory mode—Where memory leak detector runs without attempting to allocate memory.
Low memory mode is considerably slower than the normal mode and can handle only blocks. There is no support for chunks in low memory mode. Low memory mode is useful when there is little or no memory available on the router.
The memory leak detector has a simple interface and can be invoked by the command line interface (CLI) at any time to get a report of memory leaks. For testing purposes, you can perform all tests, then invoke memory leak detector to get a report on leaks. If you are interested only in leaks generated by your test cases alone, memory leak detector has an incremental option, which can be enabled at the start of testing. After testing completes, you can get a report on only the leaks that occurred after the incremental option was enabled.
To reduce false alarms, it is mandatory that memory leak detector be invoked multiple times and that only leaks that consistently appear in all reports be interpreted as leaks. This is especially true for packet buffer leaks.
Note
When submitting defects based on the reports of memory leak detector, please add "memleak-detection" to the attribute field of the defect report.
 |
Warning Executing memory leak detection commands on a device with a serious memory leak issue may cause loss of connectivity.
|
How to Use Memory Leak Detector
This section contains the following procedures:
•
Displaying Memory Leak Information
•
Setting the Memory Debug Incremental Starting Time
•
Displaying Memory Leak Information Incrementally
Displaying Memory Leak Information
To display detected memory leak information, complete the task in this section:
SUMMARY STEPS
1.
enable
2.
show memory debug leaks [chunks | largest | lowmem | summary]
DETAILED STEPS
|
|
|
Step 1 |
enable
Router> enable |
Enables privileged EXEC mode. • Enter your password if prompted. |
Step 2 |
show memory debug leaks [chunks | largest | lowmem | summary]
Router# show memory debug leaks chunks |
Invokes normal mode memory leak detection and displays detected memory leaks. Optional keywords are as follows: • chunks—Invokes normal mode memory leak detection and displays detected memory leaks in chunks. • largest—Invokes memory leak detection and displays the top ten leaking allocator_pcs and total amount of memory that they have leaked. Additionally, each time this command is invoked it remembers the previous invocation's report and compares it to the current invocation's report. • lowmem—Invokes low memory mode memory leak detection and displays detected memory leaks. The amount of time taken for analysis is considerably greater than that of normal mode. The output for this command is similar to the show memory debug leaks command. • summary—Invokes normal mode memory leak detection and displays detected memory leaks based on allocator_pc and then on the size of the block. |
Setting the Memory Debug Incremental Starting Time
To set the starting time for incremental analysis of memory leaks, complete the task in this section:
SUMMARY STEPS
1.
enable
2.
set memory debug incremental starting-time
DETAILED STEPS
|
|
|
Step 1 |
enable
Router> enable |
Enables privileged EXEC mode. • Enter your password if prompted. |
Step 2 |
set memory debug incremental starting-time
Router# set memory debug incremental starting-time |
Sets the starting time for incremental analysis to the time when the command is issued. When the starting time is set, only memory allocated after the starting time will be considered for reporting as leaks. |
Displaying Memory Leak Information Incrementally
To display memory leak information after a starting time has been established, complete the tasks in this section:
SUMMARY STEPS
1.
enable
2.
set memory debug incremental starting-time
3.
show memory debug incremental {allocations | leaks [lowmem] | status}
DETAILED STEPS
|
|
|
Step 1 |
enable
Router> enable |
Enables privileged EXEC mode. • Enter your password if prompted. |
Step 2 |
set memory debug incremental starting-time
Router# set memory debug incremental starting-time |
Sets the starting time for incremental analysis to the time when the command is issued. |
Step 3 |
show memory debug incremental {allocations | leaks [lowmem]| status}
Router# show memory debug incremental allocations |
• allocations—Displays all the memory blocks that were allocated after the issue of a set memory debug incremental starting-time command. The displayed memory blocks are just memory allocations, they are not necessarily leaks. • leaks—Displays output similar to the show memory debug leaks command, except that it displays only memory that was leaked after the issue of a set memory debug incremental starting-time command. • lowmem—Forces memory leak detection to work in low memory mode. The output for this command is similar to the show memory debug leaks command, except that it displays only memory that was leaked after the issue of a set memory debug incremental starting-time command. – In low memory mode, the analysis time is considerably greater than it is in normal mode. – You can use this command when you already know that normal mode memory leak detection will fail (perhaps by an unsuccessful previous attempt to invoke normal mode memory leak detection). • status—Displays whether a starting point for incremental analysis has been set and the elapsed time since then. |
Examples for Memory Leak Detector
The following sections provide examples of output from the show memory debug leaks and show memory debug incremental commands:
•
Example: show memory debug leaks
•
Example: show memory debug leaks chunks
•
Example: show memory debug leaks largest
•
Example: show memory debug leaks summary
•
Example: show memory debug incremental allocations
•
Example: show memory debug incremental status
Example: show memory debug leaks
The following example shows output from the show memory debug leaks command with no optional keywords specified:
Router# show memory debug leaks
Address Size Alloc_pc PID Name
Address Size Alloc_pc PID Name
Address Size Alloc_pc PID Name
62DABD28 80 60616750 -2 Init
62DABD78 80 606167A0 -2 Init
62DCF240 88 605B7E70 -2 Init
62DCF298 96 605B7E98 -2 Init
62DCF2F8 88 605B7EB4 -2 Init
62DCF350 96 605B7EDC -2 Init
63336C28 104 60C67D74 -2 Init
63370D58 96 60C656AC -2 Init
633710A0 304 60C656AC -2 Init
63B2BF68 96 60C659D4 -2 Init
63BA3FE0 32832 608D2848 104 Audit Process
63BB4020 32832 608D2FD8 104 Audit Process
Table 1 describes the significant fields shown in the display.
Table 1 show memory debug leaks Field Descriptions
|
|
Address |
Hexadecimal address of the leaked block. |
Size |
Size of the leaked block (in bytes). |
Alloc_pc |
Address of the system call that allocated the block. |
PID |
The process identifier of the process that allocated the block. |
Name |
The name of the process that allocated the block. |
Example: show memory debug leaks chunks
The following example shows output from the show memory debug leaks chunks command:
Router# show memory debug leaks chunks
Address Size Alloc_pc PID Name
Address Size Alloc_pc PID Name
Address Size Alloc_pc PID Name
62DABD28 80 60616750 -2 Init
62DABD78 80 606167A0 -2 Init
62DCF240 88 605B7E70 -2 Init
62DCF298 96 605B7E98 -2 Init
62DCF2F8 88 605B7EB4 -2 Init
62DCF350 96 605B7EDC -2 Init
63336C28 104 60C67D74 -2 Init
63370D58 96 60C656AC -2 Init
633710A0 304 60C656AC -2 Init
63B2BF68 96 60C659D4 -2 Init
63BA3FE0 32832 608D2848 104 Audit Process
63BB4020 32832 608D2FD8 104 Audit Process
62D80DA8 16 62D7BFD0 (Managed Chunk )
62D80DB8 16 62D7BFD0 (Managed Chunk )
62D80DC8 16 62D7BFD0 (Managed Chunk )
62D80DD8 16 62D7BFD0 (Managed Chunk )
62D80DE8 16 62D7BFD0 (Managed Chunk )
62E8FD60 216 62E8F888 (IPC Message He)
Table 2 describes the significant fields shown in the display.
Table 2 show memory debug leaks chunks Field Descriptions
|
|
Address |
Hexadecimal address of the leaked block. |
Size |
Size of the leaked block (in bytes). |
Alloc_pc |
Address of the system call that allocated the block. |
PID |
The process identifier of the process that allocated the block. |
Name |
The name of the process that allocated the block. |
Size |
(Chunk Elements) Size of the leaked element (bytes). |
Parent |
(Chunk Elements) Parent chunk of the leaked chunk. |
Name |
(Chunk Elements) The name of the leaked chunk. |
Example: show memory debug leaks largest
The following example shows output from the show memory debug leaks largest command:
Router# show memory debug leaks largest
608D2848 32776 inconclusive
608D2FD8 32776 inconclusive
60C656AC 288 inconclusive
The following example shows output from the second invocation of the show memory debug leaks largest command:
Router# show memory debug leaks largest
Example: show memory debug leaks summary
The following example shows output from the show memory debug leaks summary command:
Router# show memory debug leaks summary
Alloc PC Size Blocks Bytes What
Alloc PC Size Blocks Bytes What
Alloc PC Size Blocks Bytes What
0x605B7E70 0000000032 0000000001 0000000032 Init
0x605B7E98 0000000040 0000000001 0000000040 Init
0x605B7EB4 0000000032 0000000001 0000000032 Init
0x605B7EDC 0000000040 0000000001 0000000040 Init
0x60616750 0000000024 0000000001 0000000024 Init
0x606167A0 0000000024 0000000001 0000000024 Init
0x608D2848 0000032776 0000000001 0000032776 Audit Process
0x608D2FD8 0000032776 0000000001 0000032776 Audit Process
0x60C656AC 0000000040 0000000001 0000000040 Init
0x60C656AC 0000000248 0000000001 0000000248 Init
0x60C659D4 0000000040 0000000001 0000000040 Init
0x60C67D74 0000000048 0000000001 0000000048 Init
Table 3 describes the significant fields shown in the display.
Table 3 show memory debug leaks summary Field Descriptions
|
|
Alloc PC |
Address of the system call that allocated the block. |
Size |
Size of the leaked block. |
Blocks |
Number of blocks leaked. |
Bytes |
Total amount of memory leaked. |
What |
Name of the process that owns the block. |
Example: show memory debug incremental allocations
The following example shows output from the show memory debug incremental command when entered with the allocations keyword:
Router# show memory debug incremental allocations
Address Size Alloc_pc PID Name
62DA4E98 176 608CDC7C 44 CDP Protocol
62DA4F48 88 608CCCC8 44 CDP Protocol
62DA4FA0 88 606224A0 3 Exec
62DA4FF8 96 606224A0 3 Exec
635BF040 96 606224A0 3 Exec
63905E50 200 606A4DA4 69 Process Events
Example: show memory debug incremental status
The following example shows output from the show memory debug incremental command entered with the status keyword:
Router# show memory debug incremental status
Incremental debugging is enabled
Time elapsed since start of incremental debugging: 00:00:10
Additional References
The following sections provide references related to Memory Leak Detector.
Related Documents
Standards
|
|
No new or modified standards are supported by this feature, and support for existing standards has not been modified by this feature. |
— |
MIBs
|
|
No new or modified MIBs are supported by this feature, and support for existing MIBs has not been modified by this feature. |
To locate and download MIBs for selected platforms, Cisco IOS releases, and feature sets, use Cisco MIB Locator found at the following URL: http://www.cisco.com/go/mibs |
RFCs
|
|
No new or modified RFCs are supported by this feature, and support for existing RFCs has not been modified by this feature. |
— |
Technical Assistance
|
|
Technical Assistance Center (TAC) home page, containing 30,000 pages of searchable technical content, including links to products, technologies, solutions, technical tips, and tools. Registered Cisco.com users can log in from this page to access even more content. |
http://www.cisco.com/public/support/tac/home.shtml |
Feature Information for Memory Leak Detector
Table 4 lists the release history for this feature.
Use Cisco Feature Navigator to find information about platform support and software image support. Cisco Feature Navigator enables you to determine which software images support a specific software release, feature set, or platform. To access Cisco Feature Navigator, go to http://www.cisco.com/go/cfn. An account on Cisco.com is not required.
Note
Table 4 lists only the software release that introduced support for a given feature in a given software release train. Unless noted otherwise, subsequent releases of that software release train also support that feature.
Table 4 Feature Information for Memory Leak Detector
|
|
|
Memory Leak Detector |
12.3(8)T1 12.2(25)S |
The Memory Leak Detector feature is a tool that can be used to detect memory leaks on a router that is running Cisco IOS software. The Memory Leak Detector feature is capable of finding leaks in all memory pools, packet buffers, and chunks. |
Cisco and the Cisco Logo are trademarks of Cisco Systems, Inc. and/or its affiliates in the U.S. and other countries. A listing of Cisco's trademarks can be found at www.cisco.com/go/trademarks. Third party trademarks mentioned are the property of their respective owners. The use of the word partner does not imply a partnership relationship between Cisco and any other company. (1005R)
Any Internet Protocol (IP) addresses and phone numbers used in this document are not intended to be actual addresses and phone numbers. Any examples, command display output, network topology diagrams, and other figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses or phone numbers in illustrative content is unintentional and coincidental.
© 2007-2010 Cisco Systems, Inc. All rights reserved.