簡介
本文檔介紹如何對Cisco IOS®軟體平台上的MallocLite記憶體洩漏進行故障排除。
它還指定在開啟思科技術協助中心(TAC)案件或重新載入裝置之前應收集的資訊。收集本文中提到的輸出,並將其附加到TAC案例,以協助加快問題解決速度。
背景資訊
記憶體管理器使用MallocLite為小於或等於128位元組的分配,分配小的、固定大小的記憶體塊(稱為塊)。對於每次分配,小的記憶體分配沒有塊報頭的開銷。僅處理器記憶體池支援此功能。
每個記憶體塊報頭佔用大約48位元組的記憶體,最小的塊佔用大約24位元組。使用Cisco IOS軟體中的傳統方法,每次分配時,您至少會消耗72(48 + 24)位元組的記憶體,即使您只需要分配8位元組的實際資料。
使用MallocLite時,可通過使用塊來減少這種開銷。仍然有一些開銷,因為塊必須管理。然而,由於塊是固定大小,它們以不同於塊的方式管理,並且開銷較小。
使用MallocLite記憶體的應用程式有責任正確地釋放它。MallocLite遮蔽記憶體的使用者。
疑難排解
注意:Cisco CLI Analyzer(僅供已註冊客戶使用)支援某些show命令。使用 Cisco CLI Analyzer 檢視 show 指令輸出的分析。
確定應對洩漏負責的應用程式
如果僅使用malloclite關鍵字搜尋,通常難以識別現有錯誤。
此示例顯示*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命令的詳細資訊,請參閱命令參考。