您尚未登录。

#1 2016-11-30 16:02:26

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

内存越用越多是为什么?

linux内存占用

首先看图,系统开了25天后的htop,只开了个tmux和vim其他都关了,但内存占用为3.9G,而重启一下后初始内存占用仅为400M左右,我用命令

sync; echo 1> /proc/sys/vm/drop_caches

能消除缓存,但无法消除正常的内存消耗,而且内存超过限额后也会出现卡死的现象,也就是说江湖传言内存占用高其实是系统预留并不正确,但为什么在htop上看不出占用在什么地方?而其他软件关闭后为什么内存没有被完全释放?缓存了内存为下次打开更快?


learning Arch linux

离线

#2 2016-11-30 18:22:23

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 内存越用越多是为什么?

sync; echo 1> /proc/sys/vm/drop_caches

不要用这个。就像 Windows 上的XX清理专家一样,用得越多,你的系统就会越慢。

请在 htop 里按一下 H (大写),这样清晰一些。

你的内存应该是泄漏掉了。贴 /proc/meminfo 和 /proc/slabinfo 的文件内容吧。

离线

#3 2016-11-30 18:45:47

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

Re: 内存越用越多是为什么?

meminfo

MemTotal:        8059692 kB
MemFree:         1904828 kB
MemAvailable:    2478292 kB
Buffers:           41016 kB
Cached:           679156 kB
SwapCached:            0 kB
Active:          1743364 kB
Inactive:         400920 kB
Active(anon):    1441292 kB
Inactive(anon):   119688 kB
Active(file):     302072 kB
Inactive(file):   281232 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:             12984 kB
Writeback:             0 kB
AnonPages:       1111236 kB
Mapped:           376760 kB
Shmem:            136868 kB
Slab:            3913848 kB
SReclaimable:     293444 kB
SUnreclaim:      3620404 kB
KernelStack:        5760 kB
PageTables:        19984 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     4029844 kB
Committed_AS:    3276876 kB
VmallocTotal:   34359738367 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
HardwareCorrupted:     0 kB
AnonHugePages:    290816 kB
ShmemHugePages:        0 kB
ShmemPmdMapped:        0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:     1973888 kB
DirectMap2M:     6295552 kB

slabinfo

slabinfo - version: 2.1
# name            <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <limit> <batchcount> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
cifs_request          16     18  16512    1    8 : tunables    0    0    0 : slabdata     18     18      0
cifs_inode_cache     693    777    760   21    4 : tunables    0    0    0 : slabdata     37     37      0
fscache_cookie_jar     92     92     88   46    1 : tunables    0    0    0 : slabdata      2      2      0
fuse_request          80     80    400   20    2 : tunables    0    0    0 : slabdata      4      4      0
fuse_inode           117    117    832   39    8 : tunables    0    0    0 : slabdata      3      3      0
i915_gem_object      673    700    576   28    4 : tunables    0    0    0 : slabdata     25     25      0
kvm_async_pf           0      0    136   30    1 : tunables    0    0    0 : slabdata      0      0      0
kvm_vcpu               0      0  18944    1    8 : tunables    0    0    0 : slabdata      0      0      0
kvm_mmu_page_header      0      0    168   24    1 : tunables    0    0    0 : slabdata      0      0      0
ext4_groupinfo_1k     60     60    136   30    1 : tunables    0    0    0 : slabdata      2      2      0
ext4_groupinfo_4k   2044   2044    144   28    1 : tunables    0    0    0 : slabdata     73     73      0
ext4_inode_cache  176895 179880   1080   30    8 : tunables    0    0    0 : slabdata   5996   5996      0
ext4_allocation_context    128    128    128   32    1 : tunables    0    0    0 : slabdata      4      4      0
ext4_io_end          896   1152     64   64    1 : tunables    0    0    0 : slabdata     18     18      0
ext4_extent_status  79845 126480     40  102    1 : tunables    0    0    0 : slabdata   1240   1240      0
jbd2_journal_head   1632   1632    120   34    1 : tunables    0    0    0 : slabdata     48     48      0
jbd2_revoke_table_s   1024   1024     16  256    1 : tunables    0    0    0 : slabdata      4      4      0
fscrypt_info        2176   2176     32  128    1 : tunables    0    0    0 : slabdata     17     17      0
fscrypt_ctx          340    340     48   85    1 : tunables    0    0    0 : slabdata      4      4      0
mbcache              292    292     56   73    1 : tunables    0    0    0 : slabdata      4      4      0
ip6-frags              0      0    224   36    2 : tunables    0    0    0 : slabdata      0      0      0
UDPv6                168    168   1152   28    8 : tunables    0    0    0 : slabdata      6      6      0
tw_sock_TCPv6        120    120    272   30    2 : tunables    0    0    0 : slabdata      4      4      0
request_sock_TCPv6     96     96    328   24    2 : tunables    0    0    0 : slabdata      4      4      0
TCPv6                 60     60   2112   15    8 : tunables    0    0    0 : slabdata      4      4      0
bsg_cmd                0      0    312   26    2 : tunables    0    0    0 : slabdata      0      0      0
mqueue_inode_cache     36     36    896   36    8 : tunables    0    0    0 : slabdata      1      1      0
userfaultfd_ctx_cache      0      0    128   32    1 : tunables    0    0    0 : slabdata      0      0      0
pid_namespace         56     56   2224   14    8 : tunables    0    0    0 : slabdata      4      4      0
posix_timers_cache    510    510    240   34    2 : tunables    0    0    0 : slabdata     15     15      0
flow_cache             0      0    112   36    1 : tunables    0    0    0 : slabdata      0      0      0
xfrm_dst_cache       144    144    448   36    4 : tunables    0    0    0 : slabdata      4      4      0
PING                 108    108    896   36    8 : tunables    0    0    0 : slabdata      3      3      0
UDP                  442    442    960   34    8 : tunables    0    0    0 : slabdata     13     13      0
tw_sock_TCP          240    240    272   30    2 : tunables    0    0    0 : slabdata      8      8      0
request_sock_TCP      96     96    328   24    2 : tunables    0    0    0 : slabdata      4      4      0
TCP                  121    187   1920   17    8 : tunables    0    0    0 : slabdata     11     11      0
hugetlbfs_inode_cache     52     52    608   26    4 : tunables    0    0    0 : slabdata      2      2      0
dquot                224    224    256   32    2 : tunables    0    0    0 : slabdata      7      7      0
request_queue         56     56   2272   14    8 : tunables    0    0    0 : slabdata      4      4      0
blkdev_requests      122    264    368   22    2 : tunables    0    0    0 : slabdata     12     12      0
blkdev_ioc           468    468    104   39    1 : tunables    0    0    0 : slabdata     12     12      0
dmaengine-unmap-256     15     15   2112   15    8 : tunables    0    0    0 : slabdata      1      1      0
dmaengine-unmap-128     30     30   1088   30    8 : tunables    0    0    0 : slabdata      1      1      0
sock_inode_cache     740    850    640   25    4 : tunables    0    0    0 : slabdata     34     34      0
file_lock_cache      234    234    208   39    2 : tunables    0    0    0 : slabdata      6      6      0
net_namespace         20     20   6464    5    8 : tunables    0    0    0 : slabdata      4      4      0
shmem_inode_cache   2266   2645    696   23    4 : tunables    0    0    0 : slabdata    115    115      0
taskstats            120    120    328   24    2 : tunables    0    0    0 : slabdata      5      5      0
proc_inode_cache    2338   3400    648   25    4 : tunables    0    0    0 : slabdata    136    136      0
sigqueue             100    100    160   25    1 : tunables    0    0    0 : slabdata      4      4      0
bdev_cache           156    156    832   39    8 : tunables    0    0    0 : slabdata      4      4      0
kernfs_node_cache  27997  28628    120   34    1 : tunables    0    0    0 : slabdata    842    842      0
mnt_cache            383    462    384   21    2 : tunables    0    0    0 : slabdata     22     22      0
inode_cache        27071  27189    592   27    4 : tunables    0    0    0 : slabdata   1007   1007      0
dentry            297276 322959    192   21    1 : tunables    0    0    0 : slabdata  15379  15379      0
iint_cache             0      0     80   51    1 : tunables    0    0    0 : slabdata      0      0      0
buffer_head        41116  41418    104   39    1 : tunables    0    0    0 : slabdata   1062   1062      0
mm_struct            272    272    960   34    8 : tunables    0    0    0 : slabdata      8      8      0
files_cache          322    322    704   23    4 : tunables    0    0    0 : slabdata     14     14      0
signal_cache         426    540   1088   30    8 : tunables    0    0    0 : slabdata     18     18      0
sighand_cache        277    330   2112   15    8 : tunables    0    0    0 : slabdata     22     22      0
task_struct          373    504   3648    8    8 : tunables    0    0    0 : slabdata     63     63      0
cred_jar           15296  19194    192   21    1 : tunables    0    0    0 : slabdata    914    914      0
Acpi-Operand        5320   5320     72   56    1 : tunables    0    0    0 : slabdata     95     95      0
Acpi-Parse           730    730     56   73    1 : tunables    0    0    0 : slabdata     10     10      0
Acpi-State           204    204     80   51    1 : tunables    0    0    0 : slabdata      4      4      0
Acpi-Namespace      2346   2346     40  102    1 : tunables    0    0    0 : slabdata     23     23      0
anon_vma_chain     13728  18496     64   64    1 : tunables    0    0    0 : slabdata    289    289      0
anon_vma            6748   9384     80   51    1 : tunables    0    0    0 : slabdata    184    184      0
pid                 1408   1408    128   32    1 : tunables    0    0    0 : slabdata     44     44      0
numa_policy          170    170     24  170    1 : tunables    0    0    0 : slabdata      1      1      0
radix_tree_node    16881  18452    584   28    4 : tunables    0    0    0 : slabdata    659    659      0
trace_event_file    3680   3680     88   46    1 : tunables    0    0    0 : slabdata     80     80      0
ftrace_event_field  96657  98260     48   85    1 : tunables    0    0    0 : slabdata   1156   1156      0
idr_layer_cache     4005   4005   2096   15    8 : tunables    0    0    0 : slabdata    267    267      0
task_group           100    100    640   25    4 : tunables    0    0    0 : slabdata      4      4      0
dma-kmalloc-8192       0      0   8192    4    8 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-4096       0      0   4096    8    8 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-2048       0      0   2048   16    8 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-1024       0      0   1024   32    8 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-512       64     64    512   32    4 : tunables    0    0    0 : slabdata      2      2      0
dma-kmalloc-256        0      0    256   32    2 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-128        0      0    128   32    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-64         0      0     64   64    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-32         0      0     32  128    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-16         0      0     16  256    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-8          0      0      8  512    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-192        0      0    192   21    1 : tunables    0    0    0 : slabdata      0      0      0
dma-kmalloc-96         0      0     96   42    1 : tunables    0    0    0 : slabdata      0      0      0
kmalloc-8192          92    104   8192    4    8 : tunables    0    0    0 : slabdata     26     26      0
kmalloc-4096      893809 893832   4096    8    8 : tunables    0    0    0 : slabdata 111729 111729      0
kmalloc-2048         616    800   2048   16    8 : tunables    0    0    0 : slabdata     50     50      0
kmalloc-1024        1587   1984   1024   32    8 : tunables    0    0    0 : slabdata     62     62      0
kmalloc-512         1526   1696    512   32    4 : tunables    0    0    0 : slabdata     53     53      0
kmalloc-256         5453   7424    256   32    2 : tunables    0    0    0 : slabdata    232    232      0
kmalloc-192         9141   9198    192   21    1 : tunables    0    0    0 : slabdata    438    438      0
kmalloc-128         2192   3168    128   32    1 : tunables    0    0    0 : slabdata     99     99      0
kmalloc-96          3602   4494     96   42    1 : tunables    0    0    0 : slabdata    107    107      0
kmalloc-64         38848  38848     64   64    1 : tunables    0    0    0 : slabdata    607    607      0
kmalloc-32          9216   9216     32  128    1 : tunables    0    0    0 : slabdata     72     72      0
kmalloc-16         16640  16640     16  256    1 : tunables    0    0    0 : slabdata     65     65      0
kmalloc-8           7168   7168      8  512    1 : tunables    0    0    0 : slabdata     14     14      0
kmem_cache_node      320    320     64   64    1 : tunables    0    0    0 : slabdata      5      5      0
kmem_cache           150    150    320   25    2 : tunables    0    0    0 : slabdata      6      6      0

learning Arch linux

离线

#4 2016-11-30 19:16:03

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

Re: 内存越用越多是为什么?

是因为用awesome-wm才导致泄露的吗?看到用的比较高的地方,像kmalloc-4096和 VmallocTotal都不知道是什么?我有经常用局域网共享看视频之类的


learning Arch linux

离线

#5 2016-11-30 20:50:44

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 内存越用越多是为什么?

内核内存泄漏。与 Awesome 等应用程序无关。

出问题的是 kmalloc-4096 这项,占了3G多没释放……要找出原因很麻烦
你可以先猜猜看,用了哪些不一般的模块(特别是第三方的)?不用那些模块试试?

离线

#6 2016-11-30 21:19:18

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

Re: 内存越用越多是为什么?

依云 说:

内核内存泄漏。与 Awesome 等应用程序无关。

出问题的是 kmalloc-4096 这项,占了3G多没释放……要找出原因很麻烦
你可以先猜猜看,用了哪些不一般的模块(特别是第三方的)?不用那些模块试试?

我用的比较多的是chrome或者nautilus,第三方模块是指什么?虚拟机?mount?


learning Arch linux

离线

#7 2016-11-30 21:34:20

依云
会员
所在地: a.k.a. 百合仙子
注册时间: 2011-08-21
帖子: 8,384
个人网站

Re: 内存越用越多是为什么?

我说的是内核模块啦。主要是各种硬件驱动。

离线

#8 2016-11-30 22:10:33

总钻风
会员
注册时间: 2015-03-24
帖子: 64

Re: 内存越用越多是为什么?

离线

#9 2016-12-02 16:29:29

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

Re: 内存越用越多是为什么?

总钻风 说:

我笔记本的CPU是Intel的,型号是联想T420,不过我也加了黑名单试试看


learning Arch linux

离线

#10 2016-12-07 20:29:14

dxcqcv
会员
注册时间: 2012-12-28
帖子: 239

Re: 内存越用越多是为什么?

依云 说:

我说的是内核模块啦。主要是各种硬件驱动。

我再研究研究,谢谢~


learning Arch linux

离线

页脚