免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4352 | 回复: 5
打印 上一主题 下一主题

[内存管理] linux内核内存泄漏 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-09-28 20:05 |只看该作者 |倒序浏览
本帖最后由 allenhuang87 于 2014-09-30 09:08 编辑

请求各位大虾,小弟在调试上述重定向模块时,导致内核内存泄漏,查看proc文件时,看到slab内存区域明显增加,有什么办法可以定位到问题在哪呢
请各位不吝赐教,谢谢
~ # cat /proc/meminfo
MemTotal:         127032 kB
MemFree:           55712 kB
Buffers:               0 kB
Cached:            14808 kB
SwapCached:            0 kB
Active:            11556 kB
Inactive:           7036 kB
Active(anon):       3820 kB
Inactive(anon):        0 kB
Active(file):       7736 kB
Inactive(file):     7036 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:          3844 kB
Mapped:             3652 kB
Slab:              48772 kB
SReclaimable:        424 kB
SUnreclaim:        48348 kB
PageTables:          336 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       63516 kB
Committed_AS:       6816 kB
VmallocTotal:    1048404 kB
VmallocUsed:         340 kB
VmallocChunk:    1040844 kB


~ # cat /proc/slabinfo
slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
nf_conntrack_expect      0      0    144   27    1 : tunables  120   60    0 : slabdata      0      0      0
nf_conntrack          51    418    208   19    1 : tunables  120   60    0 : slabdata     22     22      0
scsi_sense_cache       1     40     96   40    1 : tunables  120   60    0 : slabdata      1      1      0
scsi_cmd_cache         1     24    160   24    1 : tunables  120   60    0 : slabdata      1      1      0
sgpool-128             2      2   2048    2    1 : tunables   24   12    0 : slabdata      1      1      0
sgpool-64              2      4   1024    4    1 : tunables   54   27    0 : slabdata      1      1      0
sgpool-32              2      8    512    8    1 : tunables   54   27    0 : slabdata      1      1      0
sgpool-16              2     15    256   15    1 : tunables  120   60    0 : slabdata      1      1      0
sgpool-8               2     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
scsi_data_buffer       0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
bridge_fdb_cache       9    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
fib6_nodes            11    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
ip6_dst_cache         21     45    256   15    1 : tunables  120   60    0 : slabdata      3      3      0
ndisc_cache            4     24    160   24    1 : tunables  120   60    0 : slabdata      1      1      0
RAWv6                  4      6    640    6    1 : tunables   54   27    0 : slabdata      1      1      0
UDPLITEv6              0      0    608    6    1 : tunables   54   27    0 : slabdata      0      0      0
UDPv6                  1      6    608    6    1 : tunables   54   27    0 : slabdata      1      1      0
tw_sock_TCPv6          1     24    160   24    1 : tunables  120   60    0 : slabdata      1      1      0
request_sock_TCPv6      0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
TCPv6                  3      6   1184    6    2 : tunables   24   12    0 : slabdata      1      1      0
flow_cache             0      0     80   48    1 : tunables  120   60    0 : slabdata      0      0      0
fuse_request           0      0    400   10    1 : tunables   54   27    0 : slabdata      0      0      0
fuse_inode             0      0    352   11    1 : tunables   54   27    0 : slabdata      0      0      0
jffs2_inode_cache   1313   1450     24  145    1 : tunables  120   60    0 : slabdata     10     10      0
jffs2_node_frag     2233   3045     24  145    1 : tunables  120   60    0 : slabdata     21     21      0
jffs2_refblock       453    480    248   16    1 : tunables  120   60    0 : slabdata     30     30      0
jffs2_tmp_dnode        0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
jffs2_raw_inode       16     56     68   56    1 : tunables  120   60    0 : slabdata      1      1      0
jffs2_raw_dirent       0      0     40   92    1 : tunables  120   60    0 : slabdata      0      0      0
jffs2_full_dnode    2330   3654     16  203    1 : tunables  120   60    0 : slabdata     18     18      0
jffs2_i              134    273    304   13    1 : tunables   54   27    0 : slabdata     21     21      0
ntfs_big_inode_cache      0      0    416    9    1 : tunables   54   27    0 : slabdata      0      0      0
ntfs_inode_cache       0      0    152   26    1 : tunables  120   60    0 : slabdata      0      0      0
ntfs_name_cache        0      0    512    8    1 : tunables   54   27    0 : slabdata      0      0      0
ntfs_attr_ctx_cache      0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
ntfs_index_ctx_cache      0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
fat_inode_cache        0      0    320   12    1 : tunables   54   27    0 : slabdata      0      0      0
fat_cache              0      0     20  169    1 : tunables  120   60    0 : slabdata      0      0      0
ext2_inode_cache       0      0    384   10    1 : tunables   54   27    0 : slabdata      0      0      0
fasync_cache           0      0     16  203    1 : tunables  120   60    0 : slabdata      0      0      0
nsproxy                0      0     24  145    1 : tunables  120   60    0 : slabdata      0      0      0
posix_timers_cache      0      0    112   35    1 : tunables  120   60    0 : slabdata      0      0      0
uid_cache              0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
UNIX                  12     20    384   10    1 : tunables   54   27    0 : slabdata      2      2      0
UDP-Lite               0      0    480    8    1 : tunables   54   27    0 : slabdata      0      0      0
tcp_bind_bucket        4    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
inet_peer_cache        2     59     64   59    1 : tunables  120   60    0 : slabdata      1      1      0
secpath_cache          0      0     32  113    1 : tunables  120   60    0 : slabdata      0      0      0
xfrm_dst_cache         0      0    288   13    1 : tunables   54   27    0 : slabdata      0      0      0
ip_fib_alias           0      0     16  203    1 : tunables  120   60    0 : slabdata      0      0      0
ip_fib_hash           17    101     36  101    1 : tunables  120   60    0 : slabdata      1      1      0
ip_dst_cache          70    165    256   15    1 : tunables  120   60    0 : slabdata     11     11      0
arp_cache             10     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
RAW                    2      8    480    8    1 : tunables   54   27    0 : slabdata      1      1      0
UDP                   24     24    480    8    1 : tunables   54   27    0 : slabdata      3      3      0
tw_sock_TCP            0      0    128   30    1 : tunables  120   60    0 : slabdata      0      0      0
request_sock_TCP       0      0     96   40    1 : tunables  120   60    0 : slabdata      0      0      0
TCP                    4     14   1056    7    2 : tunables   24   12    0 : slabdata      2      2      0
eventpoll_pwq          0      0     36  101    1 : tunables  120   60    0 : slabdata      0      0      0
eventpoll_epi          0      0     96   40    1 : tunables  120   60    0 : slabdata      0      0      0
blkdev_queue           3      7   1096    7    2 : tunables   24   12    0 : slabdata      1      1      0
blkdev_requests        8     19    200   19    1 : tunables  120   60    0 : slabdata      1      1      0
blkdev_ioc             0      0     44   84    1 : tunables  120   60    0 : slabdata      0      0      0
bio-0                  2     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
biovec-256             2      2   3072    2    2 : tunables   24   12    0 : slabdata      1      1      0
biovec-128             0      0   1536    5    2 : tunables   24   12    0 : slabdata      0      0      0
biovec-64              0      0    768    5    1 : tunables   54   27    0 : slabdata      0      0      0
biovec-16              0      0    192   20    1 : tunables  120   60    0 : slabdata      0      0      0
sock_inode_cache      84     84    320   12    1 : tunables   54   27    0 : slabdata      7      7      0
skbuff_fclone_cache      1     10    384   10    1 : tunables   54   27    0 : slabdata      1      1      0
skbuff_head_cache  18120  18120    192   20    1 : tunables  120   60    0 : slabdata    906    906      0
file_lock_cache       16     40     96   40    1 : tunables  120   60    0 : slabdata      1      1      0
proc_inode_cache     208    208    288   13    1 : tunables   54   27    0 : slabdata     16     16      0
sigqueue               8     27    144   27    1 : tunables  120   60    0 : slabdata      1      1      0
radix_tree_node      451    704     88   44    1 : tunables  120   60    0 : slabdata     16     16      0
bdev_cache             2     10    384   10    1 : tunables   54   27    0 : slabdata      1      1      0
mnt_cache             16     30    128   30    1 : tunables  120   60    0 : slabdata      1      1      0
filp                 330    570    128   30    1 : tunables  120   60    0 : slabdata     19     19      0
inode_cache          199    210    264   15    1 : tunables   54   27    0 : slabdata     14     14      0
dentry               589    960    128   30    1 : tunables  120   60    0 : slabdata     32     32      0
names_cache            4      4   4096    1    1 : tunables   24   12    0 : slabdata      4      4      0
buffer_head            0      0     64   59    1 : tunables  120   60    0 : slabdata      0      0      0
vm_area_struct       666    966     84   46    1 : tunables  120   60    0 : slabdata     21     21      0
mm_struct             39     50    384   10    1 : tunables   54   27    0 : slabdata      5      5      0
fs_cache              64    113     32  113    1 : tunables  120   60    0 : slabdata      1      1      0
files_cache           36     60    192   20    1 : tunables  120   60    0 : slabdata      3      3      0
signal_cache          90     90    448    9    1 : tunables   54   27    0 : slabdata     10     10      0
sighand_cache         54     60   3104    2    2 : tunables   24   12    0 : slabdata     30     30      0
task_struct           72     84   1112    7    2 : tunables   24   12    0 : slabdata     12     12      0
cred_jar             200    200     96   40    1 : tunables  120   60    0 : slabdata      5      5      0
anon_vma             339    678      8  339    1 : tunables  120   60    0 : slabdata      2      2      0
pid                  118    118     64   59    1 : tunables  120   60    0 : slabdata      2      2      0
idr_layer_cache       95    104    148   26    1 : tunables  120   60    0 : slabdata      4      4      0
size-4194304           0      0 4194304    1 1024 : tunables    1    1    0 : slabdata      0      0      0
size-2097152           0      0 2097152    1  512 : tunables    1    1    0 : slabdata      0      0      0
size-1048576           0      0 1048576    1  256 : tunables    1    1    0 : slabdata      0      0      0
size-524288            0      0 524288    1  128 : tunables    1    1    0 : slabdata      0      0      0
size-262144            0      0 262144    1   64 : tunables    1    1    0 : slabdata      0      0      0
size-131072            3      3 131072    1   32 : tunables    8    4    0 : slabdata      3      3      0
size-65536             0      0  65536    1   16 : tunables    8    4    0 : slabdata      0      0      0
size-32768             6      6  32768    1    8 : tunables    8    4    0 : slabdata      6      6      0
size-16384            73     73  16384    1    4 : tunables    8    4    0 : slabdata     73     73      0
size-8192            652    656   8192    1    2 : tunables    8    4    0 : slabdata    652    656      0
size-4096             38     38   4096    1    1 : tunables   24   12    0 : slabdata     38     38      0
size-2048          17492  17492   2048    2    1 : tunables   24   12    0 : slabdata   8746   8746      0
size-1024             63     80   1024    4    1 : tunables   54   27    0 : slabdata     20     20      0
size-512             416    416    512    8    1 : tunables   54   27    0 : slabdata     52     52      0
size-256             105    105    256   15    1 : tunables  120   60    0 : slabdata      7      7      0
size-192             240    240    192   20    1 : tunables  120   60    0 : slabdata     12     12      0
size-128             480    480    128   30    1 : tunables  120   60    0 : slabdata     16     16      0
size-96              380   1160     96   40    1 : tunables  120   60    0 : slabdata     29     29      0
size-64            10325  10325     64   59    1 : tunables  120   60    0 : slabdata    175    175      0
size-32             2253   2373     32  113    1 : tunables  120   60    0 : slabdata     21     21      0
kmem_cache           113    120     96   40    1 : tunables  120   60    0 : slabdata      3      3      0

论坛徽章:
9
辰龙
日期:2014-08-18 20:38:42未羊
日期:2014-09-04 08:50:45丑牛
日期:2014-09-06 00:12:55寅虎
日期:2014-12-22 20:50:56摩羯座
日期:2015-01-14 22:28:15巳蛇
日期:2015-01-23 20:39:272015年辞旧岁徽章
日期:2015-03-03 16:54:1515-16赛季CBA联赛之青岛
日期:2016-03-13 23:37:1915-16赛季CBA联赛之深圳
日期:2016-03-29 18:52:38
2 [报告]
发表于 2014-09-28 23:04 |只看该作者
唉,这么小的程序自己仔细点检测一下分配出去的内核是否都得到及时释放不就完了吗。

就你这个程序,我就怎么也找不到释放
pauth_user_have = kmalloc( sizeof(AUTHED_USER_S) ,GFP_KERNEL );
分配出来的内存的地方。

论坛徽章:
15
射手座
日期:2014-02-26 13:45:082015年迎新春徽章
日期:2015-03-04 09:54:452015年辞旧岁徽章
日期:2015-03-03 16:54:15羊年新春福章
日期:2015-02-26 08:47:552015年亚洲杯之卡塔尔
日期:2015-02-03 08:33:45射手座
日期:2014-12-31 08:36:51水瓶座
日期:2014-06-04 08:33:52天蝎座
日期:2014-05-14 14:30:41天秤座
日期:2014-04-21 08:37:08处女座
日期:2014-04-18 16:57:05戌狗
日期:2014-04-04 12:21:33技术图书徽章
日期:2014-03-25 09:00:29
3 [报告]
发表于 2014-09-29 09:00 |只看该作者
slabtop可以观察slab的变化情况~,再结合代码看~

论坛徽章:
0
4 [报告]
发表于 2014-09-30 09:09 |只看该作者
回复 2# Tinnal


    这个东西的释放是在另外一个地方的释放的!

论坛徽章:
0
5 [报告]
发表于 2014-09-30 09:11 |只看该作者
回复 3# humjb_1983


    我打开了slab_allocatorg调试,定位了问题

论坛徽章:
0
6 [报告]
发表于 2015-03-03 16:42 |只看该作者
我最近也发现了这个问题,环境是嵌入式linux,64M内存,slab数据中SUnreclaim数据一上来就很高大概在30m左右,求解,楼主应用程序出现了什么问题?别的程序内存泄漏?怎么定位的啊?回复 5# allenhuang87


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP