linux – 清除/ proc / meminfo中没有drop_caches的“缓存”内存

前端之家收集整理的这篇文章主要介绍了linux – 清除/ proc / meminfo中没有drop_caches的“缓存”内存前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个嵌入式系统运行2.6.10 linux内核(我知道!),我注意到,随着系统停留时间的延长,RAM的“缓存”使用 – 如/ proc / meminfo中所示 – 线性增加.有时它达到总RAM的70%,系统崩溃.

>我不知道为什么这个空间在内存不足的情况下不被内核自动重新声明.我认为“缓存”的内存虽然被使用,仍被认为是“可用的”.
>为了手动回收这个空间,我必须调整/ proc / sys / vm /中的drop_caches设置.但是,这个功能只在2.6.16内核中引入.

由于“缓存”中的大部分内容页面缓存,文件和inode缓存,是否有任何方式可以无需drop_caches功能即可回收它们?我已尝试同步,但这根本没有帮助.

我已经google了很多关于这一点,但是找不到任何不以某种方式依赖于drop_caches功能的资源.

编辑:

根据a few other threads的建议,我运行了一个每秒钟写入板载闪存分区的测试,我看到/ proc / slabinfo中的dentry和size-64字段都是上升的(以bash脚本的每个循环的速率为1) ).但是,我没有注意到缓存内存使用量有所增加.

更多信息:

我必须提到根目录本身是ramfs.我有一个我们读/写的闪存芯片,但是太频繁.我在崩溃之前的某个时间粘贴了meminfo和slabinfo.请注意,活动和缓存的字段如何添加到大于总可用内存的大小!

  1. MemTotal: 256708 kB
  2. MemFree: 4896 kB
  3. Buffers: 0 kB
  4. Cached: 181892 kB
  5. SwapCached: 0 kB
  6. Active: 178140 kB
  7. Inactive: 46496 kB
  8. HighTotal: 0 kB
  9. HighFree: 0 kB
  10. LowTotal: 256708 kB
  11. LowFree: 4896 kB
  12. SwapTotal: 0 kB
  13. SwapFree: 0 kB
  14. Dirty: 0 kB
  15. Writeback: 0 kB
  16. Mapped: 56656 kB
  17. Slab: 11252 kB
  18. CommitLimit: 128352 kB
  19. Committed_AS: 175668 kB
  20. PageTables: 908 kB
  21. VmallocTotal: 737280 kB
  22. VmallocUsed: 113084 kB
  23. VmallocChunk: 624100 kB
  24.  
  25. slabinfo - version: 2.1
  26. # name <active_objs> <num_objs> <objsize> <objperslab> <pagesperslab> : tunables <batchcount> <limit> <sharedfactor> : slabdata <active_slabs> <num_slabs> <sharedavail>
  27. rwsem_lock_cache 0 0 64 59 1 : tunables 120 60 0 : slabdata 0 0 0
  28. rwsem_owner_cache 16 59 64 59 1 : tunables 120 60 0 : slabdata 1 1 0
  29. rwsem_sap_cache 0 0 128 30 1 : tunables 120 60 0 : slabdata 0 0 0
  30. pss_node_cache 0 0 32 113 1 : tunables 120 60 0 : slabdata 0 0 0
  31. mts-sapinfo-cache 0 0 1152 7 2 : tunables 24 12 0 : slabdata 0 0 0
  32. mts-sap-desc-cache 34 36 448 9 1 : tunables 54 27 0 : slabdata 4 4 0
  33. mts-qentry-cache 5 59 64 59 1 : tunables 120 60 0 : slabdata 1 1 0
  34. mts-rcpnt-cache 1 1 5568 1 2 : tunables 8 4 0 : slabdata 1 1 0
  35. rpc_buffers 8 8 2048 2 1 : tunables 24 12 0 : slabdata 4 4 0
  36. rpc_tasks 8 24 160 24 1 : tunables 120 60 0 : slabdata 1 1 0
  37. rpc_inode_cache 0 0 416 9 1 : tunables 54 27 0 : slabdata 0 0 0
  38. unix_sock 70 70 384 10 1 : tunables 54 27 0 : slabdata 7 7 0
  39. tcp_tw_bucket 0 0 96 40 1 : tunables 120 60 0 : slabdata 0 0 0
  40. tcp_bind_bucket 25 203 16 203 1 : tunables 120 60 0 : slabdata 1 1 0
  41. tcp_open_request 2 59 64 59 1 : tunables 120 60 0 : slabdata 1 1 0
  42. inet_peer_cache 4 59 64 59 1 : tunables 120 60 0 : slabdata 1 1 0
  43. ip_fib_alias 23 203 16 203 1 : tunables 120 60 0 : slabdata 1 1 0
  44. ip_fib_hash 23 113 32 113 1 : tunables 120 60 0 : slabdata 1 1 0
  45. ip_dst_cache 34 45 256 15 1 : tunables 120 60 0 : slabdata 3 3 0
  46. arp_cache 13 24 160 24 1 : tunables 120 60 0 : slabdata 1 1 0
  47. raw_sock 8 8 480 8 1 : tunables 54 27 0 : slabdata 1 1 0
  48. udp_sock 7 8 480 8 1 : tunables 54 27 0 : slabdata 1 1 0
  49. tcp_sock 29 36 1024 4 1 : tunables 54 27 0 : slabdata 9 9 0
  50. flow_cache 0 0 96 40 1 : tunables 120 60 0 : slabdata 0 0 0
  51. cfq_ioc_pool 0 0 24 145 1 : tunables 120 60 0 : slabdata 0 0 0
  52. cfq_pool 0 0 104 37 1 : tunables 120 60 0 : slabdata 0 0 0
  53. crq_pool 0 0 52 72 1 : tunables 120 60 0 : slabdata 0 0 0
  54. deadline_drq 0 0 48 78 1 : tunables 120 60 0 : slabdata 0 0 0
  55. as_arq 4 63 60 63 1 : tunables 120 60 0 : slabdata 1 1 0
  56. mqueue_inode_cache 1 8 480 8 1 : tunables 54 27 0 : slabdata 1 1 0
  57. jffs2_inode_cache 24 145 24 145 1 : tunables 120 60 0 : slabdata 1 1 0
  58. jffs2_node_frag 36493 36576 28 127 1 : tunables 120 60 0 : slabdata 288 288 0
  59. jffs2_raw_node_ref 52018 52171 16 203 1 : tunables 120 60 0 : slabdata 257 257 0
  60. jffs2_tmp_dnode 0 0 24 145 1 : tunables 120 60 0 : slabdata 0 0 0
  61. jffs2_raw_inode 0 0 68 56 1 : tunables 120 60 0 : slabdata 0 0 0
  62. jffs2_raw_dirent 0 0 40 92 1 : tunables 120 60 0 : slabdata 0 0 0
  63. jffs2_full_dnode 36494 36540 16 203 1 : tunables 120 60 0 : slabdata 180 180 0
  64. jffs2_i 13 24 328 12 1 : tunables 54 27 0 : slabdata 2 2 0
  65. nfs_write_data 36 36 448 9 1 : tunables 54 27 0 : slabdata 4 4 0
  66. nfs_read_data 32 36 448 9 1 : tunables 54 27 0 : slabdata 4 4 0
  67. nfs_inode_cache 0 0 544 7 1 : tunables 54 27 0 : slabdata 0 0 0
  68. nfs_page 0 0 64 59 1 : tunables 120 60 0 : slabdata 0 0 0
  69. dnotify_cache 0 0 20 169 1 : tunables 120 60 0 : slabdata 0 0 0
  70. kioctx 0 0 192 20 1 : tunables 120 60 0 : slabdata 0 0 0
  71. kiocb 0 0 128 30 1 : tunables 120 60 0 : slabdata 0 0 0
  72. fasync_cache 0 0 16 203 1 : tunables 120 60 0 : slabdata 0 0 0
  73. shmem_inode_cache 169 170 384 10 1 : tunables 54 27 0 : slabdata 17 17 0
  74. posix_timers_cache 0 0 100 39 1 : tunables 120 60 0 : slabdata 0 0 0
  75. uid_cache 0 0 64 59 1 : tunables 120 60 0 : slabdata 0 0 0
  76. blkdev_ioc 0 0 24 145 1 : tunables 120 60 0 : slabdata 0 0 0
  77. blkdev_queue 25 30 368 10 1 : tunables 54 27 0 : slabdata 3 3 0
  78. blkdev_requests 4 28 140 28 1 : tunables 120 60 0 : slabdata 1 1 0
  79. biovec-(256) 256 256 3072 2 2 : tunables 24 12 0 : slabdata 128 128 0
  80. biovec-128 256 260 1536 5 2 : tunables 24 12 0 : slabdata 52 52 0
  81. biovec-64 256 260 768 5 1 : tunables 54 27 0 : slabdata 52 52 0
  82. biovec-16 256 260 192 20 1 : tunables 120 60 0 : slabdata 13 13 0
  83. biovec-4 256 295 64 59 1 : tunables 120 60 0 : slabdata 5 5 0
  84. biovec-1 256 406 16 203 1 : tunables 120 60 0 : slabdata 2 2 0
  85. bio 256 295 64 59 1 : tunables 120 60 0 : slabdata 5 5 0
  86. file_lock_cache 65 80 96 40 1 : tunables 120 60 0 : slabdata 2 2 0
  87. sock_inode_cache 121 121 352 11 1 : tunables 54 27 0 : slabdata 11 11 0
  88. skbuff_head_cache 560 560 192 20 1 : tunables 120 60 0 : slabdata 28 28 0
  89. sock 9 12 320 12 1 : tunables 54 27 0 : slabdata 1 1 0
  90. proc_inode_cache 1196 1196 304 13 1 : tunables 54 27 0 : slabdata 92 92 0
  91. sigqueue 26 26 148 26 1 : tunables 120 60 0 : slabdata 1 1 0
  92. radix_tree_node 2030 2030 276 14 1 : tunables 54 27 0 : slabdata 145 145 0
  93. bdev_cache 1 9 416 9 1 : tunables 54 27 0 : slabdata 1 1 0
  94. mnt_cache 20 40 96 40 1 : tunables 120 60 0 : slabdata 1 1 0
  95. inode_cache 2665 2665 288 13 1 : tunables 54 27 0 : slabdata 205 205 0
  96. dentry_cache 4147 4147 136 29 1 : tunables 120 60 0 : slabdata 143 143 0
  97. filp 1380 1440 160 24 1 : tunables 120 60 0 : slabdata 60 60 0
  98. names_cache 4 4 4096 1 1 : tunables 24 12 0 : slabdata 4 4 0
  99. idr_layer_cache 97 116 136 29 1 : tunables 120 60 0 : slabdata 4 4 0
  100. buffer_head 0 0 48 78 1 : tunables 120 60 0 : slabdata 0 0 0
  101. mm_struct 44 49 544 7 1 : tunables 54 27 0 : slabdata 7 7 0
  102. vm_area_struct 3452 3680 84 46 1 : tunables 120 60 0 : slabdata 80 80 0
  103. fs_cache 45 113 32 113 1 : tunables 120 60 0 : slabdata 1 1 0
  104. files_cache 42 45 416 9 1 : tunables 54 27 0 : slabdata 5 5 0
  105. signal_cache 57 60 256 15 1 : tunables 120 60 0 : slabdata 4 4 0
  106. sighand_cache 55 60 1312 3 1 : tunables 24 12 0 : slabdata 20 20 0
  107. task_struct 96 100 960 4 1 : tunables 54 27 0 : slabdata 25 25 0
  108. anon_vma 1273 1356 8 339 1 : tunables 120 60 0 : slabdata 4 4 0
  109. size-131072(DMA) 0 0 131072 1 32 : tunables 8 4 0 : slabdata 0 0 0
  110. size-131072 1 1 131072 1 32 : tunables 8 4 0 : slabdata 1 1 0
  111. size-65536(DMA) 0 0 65536 1 16 : tunables 8 4 0 : slabdata 0 0 0
  112. size-65536 0 0 65536 1 16 : tunables 8 4 0 : slabdata 0 0 0
  113. size-32768(DMA) 0 0 32768 1 8 : tunables 8 4 0 : slabdata 0 0 0
  114. size-32768 1 1 32768 1 8 : tunables 8 4 0 : slabdata 1 1 0
  115. size-16384(DMA) 0 0 16384 1 4 : tunables 8 4 0 : slabdata 0 0 0
  116. size-16384 8 8 16384 1 4 : tunables 8 4 0 : slabdata 8 8 0
  117. size-8192(DMA) 0 0 8192 1 2 : tunables 8 4 0 : slabdata 0 0 0
  118. size-8192 3 3 8192 1 2 : tunables 8 4 0 : slabdata 3 3 0
  119. size-4096(DMA) 0 0 4096 1 1 : tunables 24 12 0 : slabdata 0 0 0
  120. size-4096 278 278 4096 1 1 : tunables 24 12 0 : slabdata 278 278 0
  121. size-2048(DMA) 0 0 2048 2 1 : tunables 24 12 0 : slabdata 0 0 0
  122. size-2048 292 292 2048 2 1 : tunables 24 12 0 : slabdata 146 146 0
  123. size-1024(DMA) 0 0 1024 4 1 : tunables 54 27 0 : slabdata 0 0 0
  124. size-1024 60 60 1024 4 1 : tunables 54 27 0 : slabdata 15 15 0
  125. size-512(DMA) 0 0 512 8 1 : tunables 54 27 0 : slabdata 0 0 0
  126. size-512 216 216 512 8 1 : tunables 54 27 0 : slabdata 27 27 0
  127. size-256(DMA) 0 0 256 15 1 : tunables 120 60 0 : slabdata 0 0 0
  128. size-256 76 90 256 15 1 : tunables 120 60 0 : slabdata 6 6 0
  129. size-192(DMA) 0 0 192 20 1 : tunables 120 60 0 : slabdata 0 0 0
  130. size-192 139 140 192 20 1 : tunables 120 60 0 : slabdata 7 7 0
  131. size-128(DMA) 0 0 128 30 1 : tunables 120 60 0 : slabdata 0 0 0
  132. size-128 857 870 128 30 1 : tunables 120 60 0 : slabdata 29 29 0
  133. size-96(DMA) 0 0 96 40 1 : tunables 120 60 0 : slabdata 0 0 0
  134. size-96 1049 1080 96 40 1 : tunables 120 60 0 : slabdata 27 27 0
  135. size-64(DMA) 0 0 64 59 1 : tunables 120 60 0 : slabdata 0 0 0
  136. size-64 4425 4425 64 59 1 : tunables 120 60 0 : slabdata 75 75 0
  137. size-32(DMA) 0 0 32 113 1 : tunables 120 60 0 : slabdata 0 0 0
  138. size-32 4633 4633 32 113 1 : tunables 120 60 0 : slabdata 41 41 0
  139. kmem_cache 120 120 128 30 1 : tunables 120 60 0 : slabdata 4 4 0

解决方法

我想你有一个tmpfs / ramfs填满了某个地方.由于tmpfs / ramfs的工作原理,tmpfs上的文件使用的空间被Linux内核统计为“缓存”. tmpfs / ramfs上的文件基本上只是一个未回加的缓存条目.
  1. # echo 1 > /proc/sys/vm/drop_caches
  2. # grep '^Cached' /proc/meminfo
  3. Cached: 1341824 kB
  4. # dd if=/dev/zero of=/tmp/testfile bs=1G count=4
  5. 4+0 records in
  6. 4+0 records out
  7. 4294967296 bytes (4.3 GB) copied,1.33696 s,3.2 GB/s
  8. # grep '^Cached' /proc/meminfo
  9. Cached: 5543480 kB
  10. # echo 1 > /proc/sys/vm/drop_caches
  11. # grep '^Cached' /proc/meminfo
  12. Cached: 5494072 kB
  13. # rm /tmp/testfile
  14. # grep '^Cached' /proc/meminfo
  15. Cached: 1306488 kB

这是“缓存”内存,Linux无法自动恢复,因为它不受任何真正的持久性存储的支持.正如您在示例中可以看到的,即使drop_caches也不会帮助您.

所以看看/ proc / mounts是否安装了任何tmpfs / ramfs,并监视哪些正在填充.

猜你在找的Linux相关文章