简介
本文档介绍如何对Cisco IOS®软件平台上的MallocLite内存泄漏进行故障排除。
它还指定在打开思科技术支持中心(TAC)案例或重新加载设备之前应收集的信息。收集本文档中提到的输出,并将其附加到TAC案例以帮助加快问题解决。
背景信息
内存管理器使用MallocLite为小于或等于128字节的分配分配小的、固定大小的内存块(称为块)。小内存分配不会为每个分配产生块报头的开销。仅处理器内存池支持此功能。
每个内存块报头占用约48字节的内存,最小的块占用约24字节。使用Cisco IOS软件中用于每次分配的传统方法,即使您仅需要分配8个字节的实际数据,您至少会消耗72(48 + 24)字节的内存。
使用MallocLite时,可通过使用块来减少此开销。因为块必须管理,所以仍然有一些开销。但是,由于块的大小是固定的,因此它们与块的管理方式不同,开销也较低。
使用MallocLite内存的应用程序应负责正确地释放它。MallocLite屏蔽内存的用户。
故障排除
注意:Cisco CLI分析器(仅注册客户)支持某些show命令。要查看对 show 命令输出的分析,请使用思科 CLI 分析器。
确定应对泄漏负责的应用程序
如果仅使用malloclite关键字进行搜索,通常很难识别现有的Bug。
此示例显示*MallocLite*进程正在保持异常数量的内存:
#show processes memory sorted
Processor Pool Total: 1614282720 Used: 1544726580 Free: 69556140
I/O Pool Total: 313524224 Used: 115564032 Free: 197960192
PID TTY Allocated Freed Holding Getbufs Retbufs Process
0 0 0 0 1476043512 0 0 *MallocLite*
您需要确定负责泄漏的确切应用。三种可能的识别方法是:
- 解码分配器PC。
- 检查MallocLite内存统计信息。
- 禁用MallocLite。
解码分配器PC
即使打开了MallocLite,您通常也能看到需要内存的函数。show memory allocating-process totals命令的输出可能显示不同的PC值,即使报告的名称是MallocLite:
#show memory allocating-process totals
<snip>
Allocator PC Summary for: Processor
Displayed first 2048 Allocator PCs only
PC Total Count Name
0x620BE3C4 42807572 594 MallocLite
0x620ADDD4 13597308 193 MallocLite
0x60738BB0 8909824 122 MallocLite
0x620AE0E0 2060716 31 MallocLite
0x620AE10C 1982780 30 MallocLite
Cisco TAC工程师可以从列表顶部(具有最高总数)解码PC值。 这有助于识别出现内存泄漏的应用程序。
检查MallocLite内存统计信息
在Cisco IOS软件版本15.1T中添加的增强功能中,有一个新的CLI显示每台PC分配的MallocLite内存的摘要。show memory lite-chunks命令可帮助您识别使用大量MallocLite块的应用程序。
show memory lite-chunks { statistics | totals } { summary { pool | { all | pool } } }
有关show memory lite-chunks命令的详细信息,请参阅命令参考。
CLI : show memory lite-chunks totals
DESC : Summary of all pools, based on alloc pc.
This cli can be used to find the alloc_pc which is using large amount memory
allocated from all mlite pools
CLI : show memory lite-chunks statistics
DESC : Displays number of allocated & free mlite chunks
CLI : show memory lite-chunks summary pool pool
DESC : Show summary of particular mlite pool
This cli can be used to find the alloc_pc which is using large amount of memory
in individual mlite pool
CLI : show memory lite-chunks summary pool all
DESC : Show individual summary of all mlite pools
CLI : show memory lite-chunks pool pool
DESC : Show All chunk elements in the specified pool
CLI : show memory lite-chunks pool all
DESC : show all chunk elements in all mlite pools
此命令的输出示例包括:
#show memory lite-chunks ?
pool Malloc lite pool
statistics Malloc lite statistics
summary Malloc Lite summary
totals Malloc Lite Allocating totals
#show memory lite-chunks statistics
Pool Inuse Free
8-Bytes 140 1904
20-Bytes 173 1313
44-Bytes 171 791
68-Bytes 24 687
96-Bytes 26 519
128-Bytes 20 410
#show memory lite-chunks totals
PC Total Count
26067AE0 2112 33
2269E68C 1932 29
2269FACC 1664 29
2269F964 1664 26
2269FA9C 1580 29
26067FB4 1360 34
23CD2A0C 1036 7
#show memory lite-chunks pool ?
128-Bytes 128 bytes pool
20-Bytes 20 bytes pool
44-Bytes 44 bytes pool
68-Bytes 68 bytes pool
8-Bytes 8 bytes pool
96-Bytes 96 bytes pool
all all pools
#show memory lite-chunks summary pool 8
8 bytes pool
PC Total Count
2269FB10 812 29
23612084 700 25
2269F9F8 700 25
2269F9EC 700 25
同样,TAC工程师可以解码最高总量的PC值,并识别正在泄露内存的应用。
禁用MallocLite
缺省情况下,启用MallocLite功能。为了调查MallocLite泄漏,您可以禁用MallocLite:
(config)#no memory lite
泄漏的内存仍将在MallocLite下运行,直到下一次重新加载;但是,您可以使用show processes memory sorted和show memory allocating-process totals命令开始监控进一步的泄漏。泄漏现在将出现在真实流程中。
如果设备的内存非常低,则必须保存配置并重新加载设备以释放内存:
#wr
#reload
内存可能会随时间再次耗尽,因此请使用show processes memory sorted和show memory allocating-process totals命令来监控从此点开始的内存使用情况。
注意:如果使用no memory lite命令有效地禁用MallocLite并重新加载设备,show memory lite-chunks命令的输出将为空。
有关memory lite命令的详细信息,请参阅命令参考。