Table Of Contents
Information About Memory Leak Detector
How to Use Memory Leak Detector
Displaying Memory Leak Information
Setting the Memory Debug Incremental Starting Time
Displaying Memory Leak Information Incrementally
set memory debug incremental starting-time
Memory Leak Detector
First Published: May 17, 2004Last Updated: June 1, 2006The 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.
History for the Memory Leak Detector Feature
Finding Support Information for Platforms and Cisco IOS and Catalyst OS Software Images
Use Cisco Feature Navigator to find information about platform support and software image support. Cisco Feature Navigator enables you to determine which Cisco IOS and Catalyst OS 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.
Contents
•
Information About Memory Leak Detector
•
How to Use Memory Leak Detector
Information About Memory Leak Detector
Before using the Memory Leak Detector feature, you should understand the following concepts:
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.
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
This task describes how to display detected memory leak information.
SUMMARY STEPS
1.
enable
2.
show memory debug leaks [chunks | largest | lowmem | summary]
DETAILED STEPS
Examples
This section provides the following output examples:
•
Sample Output for the show memory debug leaks Command
•
Sample Output for the show memory debug leaks chunks Command
•
Sample Output for the show memory debug leaks largest Command
•
Sample Output for the show memory debug leaks summary Command
Sample Output for the show memory debug leaks Command
The following example shows output from the show memory debug leaks command with no optional keywords specified:
Router# show memory debug leaksAdding blocks for GD...PCI memoryAddress Size Alloc_pc PID NameI/O memoryAddress Size Alloc_pc PID NameProcessor memoryAddress Size Alloc_pc PID Name62DABD28 80 60616750 -2 Init62DABD78 80 606167A0 -2 Init62DCF240 88 605B7E70 -2 Init62DCF298 96 605B7E98 -2 Init62DCF2F8 88 605B7EB4 -2 Init62DCF350 96 605B7EDC -2 Init63336C28 104 60C67D74 -2 Init63370D58 96 60C656AC -2 Init633710A0 304 60C656AC -2 Init63B2BF68 96 60C659D4 -2 Init63BA3FE0 32832 608D2848 104 Audit Process63BB4020 32832 608D2FD8 104 Audit ProcessTable 1 describes the significant fields shown in the display.
Sample Output for the show memory debug leaks chunks Command
The following example shows output from the show memory debug leaks chunks command:
Router# show memory debug leaks chunksAdding blocks for GD...PCI memoryAddress Size Alloc_pc PID NameChunk Elements:Address Size Parent NameI/O memoryAddress Size Alloc_pc PID NameChunk Elements:Address Size Parent NameProcessor memoryAddress Size Alloc_pc PID Name62DABD28 80 60616750 -2 Init62DABD78 80 606167A0 -2 Init62DCF240 88 605B7E70 -2 Init62DCF298 96 605B7E98 -2 Init62DCF2F8 88 605B7EB4 -2 Init62DCF350 96 605B7EDC -2 Init63336C28 104 60C67D74 -2 Init63370D58 96 60C656AC -2 Init633710A0 304 60C656AC -2 Init63B2BF68 96 60C659D4 -2 Init63BA3FE0 32832 608D2848 104 Audit Process63BB4020 32832 608D2FD8 104 Audit ProcessChunk Elements:Address Size Parent Name62D80DA8 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.
Sample Output for the show memory debug leaks largest Command
The following example shows output from the show memory debug leaks largest command:
Router# show memory debug leaks largestAdding blocks for GD...PCI memoryAlloc_pc total leak sizeI/O memoryAlloc_pc total leak sizeProcessor memoryAlloc_pc total leak size608D2848 32776 inconclusive608D2FD8 32776 inconclusive60C656AC 288 inconclusive60C67D74 48 inconclusive605B7E98 40 inconclusive605B7EDC 40 inconclusive60C659D4 40 inconclusive605B7E70 32 inconclusive605B7EB4 32 inconclusive60616750 24 inconclusiveThe following example shows output from the second invocation of the show memory debug leaks largest command:
Router# show memory debug leaks largestAdding blocks for GD...PCI memoryAlloc_pc total leak sizeI/O memoryAlloc_pc total leak sizeProcessor memoryAlloc_pc total leak size608D2848 32776608D2FD8 3277660C656AC 28860C67D74 48605B7E98 40605B7EDC 4060C659D4 40605B7E70 32605B7EB4 3260616750 24Sample Output for the show memory debug leaks summary Command
The following example shows output from the show memory debug leaks summary command:
Router# show memory debug leaks summaryAdding blocks for GD...PCI memoryAlloc PC Size Blocks Bytes WhatI/O memoryAlloc PC Size Blocks Bytes WhatProcessor memoryAlloc PC Size Blocks Bytes What0x605B7E70 0000000032 0000000001 0000000032 Init0x605B7E98 0000000040 0000000001 0000000040 Init0x605B7EB4 0000000032 0000000001 0000000032 Init0x605B7EDC 0000000040 0000000001 0000000040 Init0x60616750 0000000024 0000000001 0000000024 Init0x606167A0 0000000024 0000000001 0000000024 Init0x608D2848 0000032776 0000000001 0000032776 Audit Process0x608D2FD8 0000032776 0000000001 0000032776 Audit Process0x60C656AC 0000000040 0000000001 0000000040 Init0x60C656AC 0000000248 0000000001 0000000248 Init0x60C659D4 0000000040 0000000001 0000000040 Init0x60C67D74 0000000048 0000000001 0000000048 InitTable 3 describes the significant fields shown in the display.
Setting the Memory Debug Incremental Starting Time
This task describes how to set the starting time for incremental analysis of memory leaks. For incremental analysis, you can define a starting point by using the set memory debug incremental starting-time command. When the starting time is set, only memory allocated after the starting time will be considered for reporting as leaks.
SUMMARY STEPS
1.
enable
2.
set memory debug incremental starting-time
DETAILED STEPS
Displaying Memory Leak Information Incrementally
This task describes how to display memory leak information after a starting time has been established.
SUMMARY STEPS
1.
enable
2.
set memory debug incremental starting-time
3.
show memory debug incremental {allocations | leaks [lowmem] | status}
DETAILED STEPS
Examples
This section provides the following output examples:
•
Sample Output for the show memory debug incremental allocations Command
•
Sample Output for the show memory debug incremental status Command
Sample Output for the show memory debug incremental allocations Command
The following example shows output from the show memory debug incremental command when entered with the allocations keyword:
Router# show memory debug incremental allocationsAddress Size Alloc_pc PID Name62DA4E98 176 608CDC7C 44 CDP Protocol62DA4F48 88 608CCCC8 44 CDP Protocol62DA4FA0 88 606224A0 3 Exec62DA4FF8 96 606224A0 3 Exec635BF040 96 606224A0 3 Exec63905E50 200 606A4DA4 69 Process EventsSample Output for the show memory debug incremental status Command
The following example shows output from the show memory debug incremental command entered with the status keyword:
Router# show memory debug incremental statusIncremental debugging is enabledTime elapsed since start of incremental debugging: 00:00:10Additional References
The following sections provide references related to Memory Leak Detector.
Related Documents
Related Topic Document TitleAdditional commands: complete command syntax, command mode, defaults, usage guidelines, and examples
The Cisco IOS Configuration Fundamentals and Network Management Command Reference, Release 12.3 T
Standards
MIBs
MIBs MIBs LinkNone
To locate and download MIBs for selected platforms, Cisco IOS releases, and feature sets, use Cisco MIB Locator found at the following URL:
RFCs
Technical Assistance
Command Reference
This section documents modified commands only.
•
set memory debug incremental starting-time
•
show memory debug incremental
set memory debug incremental starting-time
To set the current time as the starting time for incremental analysis, use the set memory debug incremental starting-time command in privileged EXEC mode.
set memory debug incremental starting-time [none]
Syntax Description
Defaults
No default behavior or values.
Command Modes
Privileged EXEC
Command History
Usage Guidelines
For incremental analysis, a starting point can be defined by using the set memory debug incremental starting-time command. When a starting time is set, only memory allocated after that starting time will be considered for reporting as leaks.
Examples
The following example shows the command used to set the starting time for incremental analysis to the time when the command was issued:
Router# set memory debug incremental starting-timeRelated Commands
show memory debug incremental
To display information about memory leaks after a starting time has been established, use the show memory debug incremental command in privileged EXEC mode.
show memory debug incremental {allocations | leaks [lowmem] | status}
Syntax Description
Command Modes
Privileged EXEC
Command History
Release Modification12.3(7)T
This command was introduced.
12.2(33)SRA
This command was integrated into Cisco IOS Release 12.2(33)SRA.
Usage Guidelines
The show memory debug incremental allocations command 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.
The show memory debug incremental leaks command provides 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.
The show memory debug incremental leaks lowmem command forces memory leak detection to work in low memory mode. 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, except that it displays only memory that was leaked after the issue of a set memory debug incremental starting-time command. 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).
The show memory debug incremental status command displays whether a starting point for incremental analysis has been set and the elapsed time since then.
Note
All memory leak detection commands invoke normal mode memory leak detection, except when the low memory option is specifically invoked by use of the lowmem keyword. In normal mode, if memory leak detection determines that there is insufficient memory to proceed in normal mode, it will display an appropriate message and switch to low memory mode.
Examples
show memory debug incremental allocations Command Example
The following example shows output from the show memory debug incremental command when entered with the allocations keyword:
Router# show memory debug incremental allocationsAddress Size Alloc_pc PID Name62DA4E98 176 608CDC7C 44 CDP Protocol62DA4F48 88 608CCCC8 44 CDP Protocol62DA4FA0 88 606224A0 3 Exec62DA4FF8 96 606224A0 3 Exec635BF040 96 606224A0 3 Exec63905E50 200 606A4DA4 69 Process Eventsshow memory debug incremental status Command Example
The following example shows output from the show memory debug incremental command entered with the status keyword:
Router# show memory debug incremental statusIncremental debugging is enabledTime elapsed since start of incremental debugging: 00:00:10Related Commands
Command Descriptionset memory debug incremental starting-time
Sets the current time as the starting time for incremental analysis.
show memory debug leaks
Displays detected memory leaks.
show memory debug leaks
To display detected memory leaks, use the show memory debug leaks command in privileged EXEC mode.
show memory debug leaks [chunks | largest | lowmem | summary]
Syntax Description
Command Modes
Privileged EXEC
Command History
Usage Guidelines
If no optional keywords are specified, the show memory debug leaks command invokes normal mode memory leak detection and does not look for memory leaks in chunks.
The show memory debug leaks chunks command invokes normal mode memory leak detection and looks for leaks in chunks as well.
The show memory debug leaks largest command displays the top ten leaking allocator_pcs and the 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. If there are new entries in the current report they are tagged as "inconclusive." If the same entry appears in the previous invocation's report and the current invocation's report, the inconclusive tag is not added. It would be beneficial to run memory leak detection more than once and to consider only the consistently reported leaks.
The show memory debug leaks lowmem command forces memory leak detection to work in low memory mode. 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. 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).
The show memory debug leaks summary command reports memory leaks based on allocator_pc and then on the size of the block.
Note
All memory leak detection commands invoke normal mode memory leak detection, except when the low memory option is specifically invoked by use of the lowmem keyword. In normal mode, if memory leak detection determines that there is insufficient memory to proceed in normal mode, it will display an appropriate message and switch to low memory mode.
Examples
show memory debug leaks Command Example
The following example shows output from the show memory debug leaks command:
Router# show memory debug leaksAdding blocks for GD...PCI memoryAddress Size Alloc_pc PID NameI/O memoryAddress Size Alloc_pc PID NameProcessor memoryAddress Size Alloc_pc PID Name62DABD28 80 60616750 -2 Init62DABD78 80 606167A0 -2 Init62DCF240 88 605B7E70 -2 Init62DCF298 96 605B7E98 -2 Init62DCF2F8 88 605B7EB4 -2 Init62DCF350 96 605B7EDC -2 Init63336C28 104 60C67D74 -2 Init63370D58 96 60C656AC -2 Init633710A0 304 60C656AC -2 Init63B2BF68 96 60C659D4 -2 Init63BA3FE0 32832 608D2848 104 Audit Process63BB4020 32832 608D2FD8 104 Audit ProcessTable 4 describes the significant fields shown in the display.
show memory debug leaks chunks Command Example
The following example shows output from the show memory debug leaks chunks command:
Router# show memory debug leaks chunksAdding blocks for GD...PCI memoryAddress Size Alloc_pc PID NameChunk Elements:Address Size Parent NameI/O memoryAddress Size Alloc_pc PID NameChunk Elements:Address Size Parent NameProcessor memoryAddress Size Alloc_pc PID Name62DABD28 80 60616750 -2 Init62DABD78 80 606167A0 -2 Init62DCF240 88 605B7E70 -2 Init62DCF298 96 605B7E98 -2 Init62DCF2F8 88 605B7EB4 -2 Init62DCF350 96 605B7EDC -2 Init63336C28 104 60C67D74 -2 Init63370D58 96 60C656AC -2 Init633710A0 304 60C656AC -2 Init63B2BF68 96 60C659D4 -2 Init63BA3FE0 32832 608D2848 104 Audit Process63BB4020 32832 608D2FD8 104 Audit ProcessChunk Elements:Address Size Parent Name62D80DA8 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 5 describes the significant fields shown in the display.
show memory debug leaks largest Command Example
The following example shows output from the show memory debug leaks largest command:
Router# show memory debug leaks largestAdding blocks for GD...PCI memoryAlloc_pc total leak sizeI/O memoryAlloc_pc total leak sizeProcessor memoryAlloc_pc total leak size608D2848 32776 inconclusive608D2FD8 32776 inconclusive60C656AC 288 inconclusive60C67D74 48 inconclusive605B7E98 40 inconclusive605B7EDC 40 inconclusive60C659D4 40 inconclusive605B7E70 32 inconclusive605B7EB4 32 inconclusive60616750 24 inconclusiveThe following example shows output from the second invocation of the show memory debug leaks largest command:
Router# show memory debug leaks largestAdding blocks for GD...PCI memoryAlloc_pc total leak sizeI/O memoryAlloc_pc total leak sizeProcessor memoryAlloc_pc total leak size608D2848 32776608D2FD8 3277660C656AC 28860C67D74 48605B7E98 40605B7EDC 4060C659D4 40605B7E70 32605B7EB4 3260616750 24show memory debug leaks summary Command Example
The following example shows output from the show memory debug leaks summary command:
Router# show memory debug leaks summaryAdding blocks for GD...PCI memoryAlloc PC Size Blocks Bytes WhatI/O memoryAlloc PC Size Blocks Bytes WhatProcessor memoryAlloc PC Size Blocks Bytes What0x605B7E70 0000000032 0000000001 0000000032 Init0x605B7E98 0000000040 0000000001 0000000040 Init0x605B7EB4 0000000032 0000000001 0000000032 Init0x605B7EDC 0000000040 0000000001 0000000040 Init0x60616750 0000000024 0000000001 0000000024 Init0x606167A0 0000000024 0000000001 0000000024 Init0x608D2848 0000032776 0000000001 0000032776 Audit Process0x608D2FD8 0000032776 0000000001 0000032776 Audit Process0x60C656AC 0000000040 0000000001 0000000040 Init0x60C656AC 0000000248 0000000001 0000000248 Init0x60C659D4 0000000040 0000000001 0000000040 Init0x60C67D74 0000000048 0000000001 0000000048 InitTable 6 describes the significant fields shown in the display.
Related Commands
Any Internet Protocol (IP) addresses used in this document are not intended to be actual addresses. Any examples, command display output, and figures included in the document are shown for illustrative purposes only. Any use of actual IP addresses in illustrative content is unintentional and coincidental.
© 2004, 2006 Cisco Systems, Inc. All rights reserved.


