网站转化率低,免费素材网站素材库,seo算法入门教程,wordpress会员中心vip收费1#xff0c;当遇到内存增加过多时#xff0c;或者由于内存导致系统oom时我们怎么定位呢#xff0c;定位时需要确认是内核态还是用户态内存泄露。
排查步骤
top查看VIRT和RES内存 rootubuntu2004:~# top top - 21:05:39 up 7 min, 1 user, load average: 5.01, 4.09, 2.…1当遇到内存增加过多时或者由于内存导致系统oom时我们怎么定位呢定位时需要确认是内核态还是用户态内存泄露。
排查步骤
top查看VIRT和RES内存 rootubuntu2004:~# top top - 21:05:39 up 7 min, 1 user, load average: 5.01, 4.09, 2.08 Tasks: 189 total, 1 running, 188 sleeping, 0 stopped, 0 zombie %Cpu(s): 0.2 us, 0.4 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st MiB Mem : 1957.0 total, 1127.2 free, 420.2 used, 409.6 buff/cache MiB Swap: 0.0 total, 0.0 free, 0.0 used. 1507.5 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME COMMAND 624 root 20 0 572632 130848 88464 S 0.0 6.5 0:05.54 Xorg 840 rpdzkj 20 0 1023136 78336 56980 S 0.0 3.9 0:02.72 xfwm4 966 rpdzkj 20 0 680868 66272 52292 S 0.0 3.3 0:01.06 evoluti 714 rpdzkj 20 0 378496 57528 43640 S 0.0 2.9 0:01.55 xfce4-s 957 rpdzkj 20 0 296700 55016 29824 S 0.0 2.7 0:07.41 onboard 1037 rpdzkj 20 0 360260 47704 28668 S 0.0 2.4 0:02.58 blueman 964 rpdzkj 20 0 431776 44016 26368 S 0.0 2.2 0:03.17 blueman 941 rpdzkj 20 0 498700 36672 29316 S 0.0 1.8 0:02.71 panel-8 967 rpdzkj 20 0 276012 35068 20404 S 0.0 1.7 0:01.51 udiskie 954 rpdzkj 20 0 425520 34976 27232 S 0.0 1.7 0:18.35 nm-appl 942 rpdzkj 20 0 231988 34744 27904 S 0.0 1.7 0:00.51 panel-1 937 rpdzkj 20 0 273236 34304 23384 S 0.0 1.7 0:01.37 xfdeskt 909 rpdzkj 20 0 268888 30152 23612 S 0.0 1.5 0:00.91 xfce4-p 989 rpdzkj 20 0 268392 28776 22956 S 0.0 1.4 0:00.69 xfce4-n 1029 rpdzkj 20 0 837080 27936 24056 S 0.0 1.4 0:00.59 evoluti 1064 rpdzkj 20 0 672056 27340 23704 S 0.0 1.4 0:00.33 evoluti 943 rpdzkj 20 0 190136 24608 19268 S 0.0 1.2 0:00.40 panel-1 shirftM 可以排序查看内存的排序。
2,ps -aux rootubuntu2004:~# ps -aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 1.3 0.4 169072 9708 ? Ss 20:57 0:12 /sbin/init root 2 0.0 0.0 0 0 ? S 20:57 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? I 20:57 0:00 [rcu_gp] root 4 0.0 0.0 0 0 ? I 20:57 0:00 [rcu_par_gp] root 5 0.1 0.0 0 0 ? I 20:57 0:01 [kworker/0:0- root 8 0.0 0.0 0 0 ? I 20:57 0:00 [mm_percpu_wq root 9 0.0 0.0 0 0 ? S 20:57 0:00 [rcu_tasks_ru root 10 0.0 0.0 0 0 ? S 20:57 0:00 [rcu_tasks_tr root 11 0.0 0.0 0 0 ? S 20:57 0:00 [ksoftirqd/0] root 12 0.1 0.0 0 0 ? I 20:57 0:00 [rcu_sched] root 13 0.0 0.0 0 0 ? S 20:57 0:00 [migration/0] root 14 0.0 0.0 0 0 ? S 20:57 0:00 [cpuhp/0] root 15 0.0 0.0 0 0 ? S 20:57 0:00 [cpuhp/1] root 16 0.0 0.0 0 0 ? S 20:57 0:00 [migration/1] root 17 0.0 0.0 0 0 ? S 20:57 0:00 [ksoftirqd/1] root 19 0.0 0.0 0 0 ? I 20:57 0:00 [kworker/1:0H root 20 0.0 0.0 0 0 ? S 20:57 0:00 [cpuhp/2] root 21 0.0 0.0 0 0 ? S 20:57 0:00 [migration/2] root 22 0.0 0.0 0 0 ? S 20:57 0:00 [ksoftirqd/2] root 25 0.0 0.0 0 0 ? S 20:57 0:00 [cpuhp/3] root 26 0.0 0.0 0 0 ? S 20:57 0:00 [migration/3] root 27 0.0 0.0 0 0 ? S 20:57 0:00 [ksoftirqd/3] root 30 0.0 0.0 0 0 ? S 20:57 0:00 [kdevtmpfs] root 31 0.0 0.0 0 0 ? I 20:57 0:00 [netns] root 36 0.0 0.0 0 0 ? S 20:57 0:00 [kauditd] root 37 0.0 0.0 0 0 ? S 20:57 0:00 [oom_reaper] root 38 0.0 0.0 0 0 ? I 20:57 0:00 [writeback] root 83 0.0 0.0 0 0 ? I 20:57 0:00 [kblockd] root 84 0.0 0.0 0 0 ? I 20:57 0:00 [blkcg_punt_b root 85 0.0 0.0 0 0 ? D 20:58 0:00 [kconsole] root 86 0.0 0.0 0 0 ? I 20:58 0:00 [tpm_dev_wq] root 87 0.0 0.0 0 0 ? I 20:58 0:00 [edac-poller] root 88 0.0 0.0 0 0 ? I 20:58 0:00 [devfreq_wq] root 89 0.0 0.0 0 0 ? S 20:58 0:00 [watchdogd] root 90 0.0 0.0 0 0 ? I 20:58 0:00 [kworker/u8:1 root 92 0.0 0.0 0 0 ? I 20:58 0:00 [rpciod] root 93 0.0 0.0 0 0 ? I 20:58 0:00 [kworker/u9:0 root 94 0.0 0.0 0 0 ? I 20:58 0:00 [xprtiod] root 95 0.0 0.0 0 0 ? I 20:58 0:00 [cfg80211] root 96 0.0 0.0 0 0 ? S 20:58 0:00 [irq/75-rockc root 116 0.0 0.0 0 0 ? S 20:58 0:00 [kswapd0] root 117 0.0 0.0 0 0 ? I 20:58 0:00 [nfsiod] root 118 0.0 0.0 0 0 ? I 20:58 0:00 [xfsalloc] root 119 0.0 0.0 0 0 ? I 20:58 0:00 [xfs_mru_cach root 121 0.0 0.0 0 0 ? I 20:58 0:00 [kthrotld] root 122 0.0 0.0 0 0 ? S 20:58 0:00 [irq/77-rockc root 124 0.0 0.0 0 0 ? I 20:58 0:00 [kworker/3:3- root 125 0.0 0.0 0 0 ? S 20:58 0:00 [irq/78-rockc root 126 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work0] root 127 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work1] root 128 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work2] root 129 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work3] root 130 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work4] root 131 0.0 0.0 0 0 ? S 20:58 0:00 [queue_work5] root 132 0.0 0.0 0 0 ? S 20:58 0:00 [irq/30-fdea0 root 133 0.0 0.0 0 0 ? S 20:58 0:00 [irq/35-fdee0 root 134 0.0 0.0 0 0 ? S 20:58 0:00 [irq/37-fdef0 root 135 0.0 0.0 0 0 ? S 20:58 0:00 [irq/33-fded0 root 136 0.0 0.0 0 0 ? S 20:58 0:00 [hwrng] root 137 0.0 0.0 0 0 ? I 20:58 0:00 [hpd_queue] 查看 VSZ 和RSS 的变化。
3.smem
后面补充
4,cat /proc/pid/status rootubuntu2004:~# cat /proc/624/status Name: Xorg Umask: 0022 State: S (sleeping) Tgid: 624 Ngid: 0 Pid: 624 PPid: 616 TracerPid: 0 Uid: 0 0 0 0 Gid: 0 0 0 0 FDSize: 128 Groups: NStgid: 624 NSpid: 624 NSpgid: 624 NSsid: 624 VmPeak: 598904 kB VmSize: 572632 kB VmLck: 0 kB VmPin: 0 kB VmHWM: 138316 kB VmRSS: 130848 kB RssAnon: 42384 kB RssFile: 87460 kB RssShmem: 1004 kB VmData: 107784 kB VmStk: 132 kB VmExe: 2368 kB VmLib: 158448 kB VmPTE: 512 kB VmSwap: 0 kB HugetlbPages: 0 kB CoreDumping: 0 THP_enabled: 0 Threads: 9 SigQ: 1/7734 SigPnd: 0000000000000000 ShdPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000301000 SigCgt: 00000001c18066ef CapInh: 0000000000000000 CapPrm: 000001ffffffffff CapEff: 000001ffffffffff CapBnd: 000001ffffffffff CapAmb: 0000000000000000 NoNewPrivs: 0 Seccomp: 0 Seccomp_filters: 0 Speculation_Store_Bypass: not vulnerable Cpus_allowed: f Cpus_allowed_list: 0-3 Mems_allowed: 1 Mems_allowed_list: 0 voluntary_ctxt_switches: 9753 nonvoluntary_ctxt_switches: 2738 VmSize表示的是VSSVmRSS表示的是RSS
查看所有进程的累加 rootubuntu2004:~# cat /proc/624/smaps | grep Rss | awk {Total$2} END {print TotalKB} 107248KB rootubuntu2004:~# cat /proc/624/smaps | grep Pss | awk {Total$2} END {print TotalKB} 77434KB 查看vss和res物理内存有没有增加如果有明显增加可以确定是用户态的内存泄漏可以使用valgrind来定位问题。
如果用户态内存没看到有明显增加就需要考虑是不是内核态的泄露了。
首先通过cat proc/meminfo来查看unReclamiable slab memory有没有明显变化。 rootubuntu2004:~# cat /proc/meminfo MemTotal: 2003988 kB MemFree: 1155916 kB MemAvailable: 1544148 kB Buffers: 18900 kB Cached: 362320 kB SwapCached: 0 kB Active: 76116 kB Inactive: 612384 kB Active(anon): 732 kB Inactive(anon): 311648 kB Active(file): 75384 kB Inactive(file): 300736 kB Unevictable: 3784 kB Mlocked: 0 kB SwapTotal: 0 kB SwapFree: 0 kB Dirty: 208 kB Writeback: 0 kB AnonPages: 311072 kB Mapped: 180516 kB Shmem: 5096 kB KReclaimable: 37040 kB Slab: 83124 kB SReclaimable: 37040 kB SUnreclaim: 46084 kB KernelStack: 5424 kB PageTables: 7728 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 1001992 kB Committed_AS: 1742756 kB VmallocTotal: 263061440 kB VmallocUsed: 16196 kB VmallocChunk: 0 kB Percpu: 1632 kB CmaTotal: 16384 kB CmaAllocated: 2064 kB CmaReleased: 14320 kB CmaFree: 2124 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB Hugetlb: 0 kB 查看SReclaimable的内存变化情况。
首先通过cat proc/slabinfo来查看kmalloc的内存没有明显变化如果有的话就可以确认是内核态的泄露。 rootubuntu2004:~# 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 ext4_groupinfo_4k 56 56 144 28 1 : tunables 0 0 0 : slabdata 2 2 0 btrfs_delayed_tree_ref 0 0 104 39 1 : tunables 0 0 0 : slabdata 0 0 0 btrfs_delayed_node 0 0 312 26 2 : tunables 0 0 0 : slabdata 0 0 0 btrfs_ordered_extent 0 0 408 20 2 : tunables 0 0 0 : slabdata 0 0 0 btrfs_extent_map 0 0 144 28 1 : tunables 0 0 0 : slabdata 0 0 0 bio-3 21 21 384 21 2 : tunables 0 0 0 : slabdata 1 1 0 btrfs_path 0 0 112 36 1 : tunables 0 0 0 : slabdata 0 0 0 btrfs_inode 0 0 1152 28 8 : tunables 0 0 0 : slabdata 0 0 0 ubifs_inode_slab 0 0 760 21 4 : tunables 0 0 0 : slabdata 0 0 0 PINGv6 0 0 1216 26 8 : tunables 0 0 0 : slabdata 0 0 0 RAWv6 78 78 1216 26 8 : tunables 0 0 0 : slabdata 3 3 0 UDPv6 72 72 1344 24 8 : tunables 0 0 0 : slabdata 3 3 0 tw_sock_TCPv6 0 0 240 17 1 : tunables 0 0 0 : slabdata 0 0 0 request_sock_TCPv6 0 0 304 26 2 : tunables 0 0 0 : slabdata 0 0 0 TCPv6 26 26 2368 13 8 : tunables 0 0 0 : slabdata 2 2 0 nf_conntrack_expect 0 0 216 18 1 : tunables 0 0 0 : slabdata 0 0 0 nf_conntrack 0 0 256 16 1 : tunables 0 0 0 : slabdata 0 0 0 dm_bio_prison_cell 0 0 96 42 1 : tunables 0 0 0 : slabdata 0 0 0 kcopyd_job 0 0 3312 9 8 : tunables 0 0 0 : slabdata 0 0 0 lkdtm-heap-b 0 0 72 56 1 : tunables 0 0 0 : slabdata 0 0 0 lkdtm-heap-a 0 0 72 56 1 : tunables 0 0 0 : slabdata 0 0 0 lkdtm-heap-double_free 0 0 72 56 1 : tunables 0 0 0 : slabdata 0 0 0 lkdtm-usercopy 0 0 1024 16 4 : tunables 0 0 0 : slabdata 0 0 0 mqueue_inode_cache 17 17 960 17 4 : tunables 0 0 0 : slabdata 1 1 0 xfs_buf 0 0 384 21 2 : tunables 0 0 0 : slabdata 0 0 0 xfs_rui_item 0 0 680 24 4 : tunables 0 0 0 : slabdata 0 0 0 xfs_rud_item 240 240 168 24 1 : tunables 0 0 0 : slabdata 10 10 0 xfs_icr 0 0 176 23 1 : tunables 0 0 0 : slabdata 0 0 0 xfs_inode 0 0 960 17 4 : tunables 0 0 0 : slabdata 0 0 0 xfs_efi_item 0 0 424 19 2 : tunables 0 0 0 : slabdata 0 0 0 xfs_efd_item 0 0 432 18 2 : tunables 0 0 0 : slabdata 0 0 0 xfs_buf_item 0 0 264 31 2 : tunables 0 0 0 : slabdata 0 0 0 xfs_da_state 0 0 480 17 2 : tunables 0 0 0 : slabdata 0 0 0 xfs_btree_cur 0 0 224 18 1 : tunables 0 0 0 : slabdata 0 0 0 xfs_log_ticket 0 0 184 22 1 : tunables 0 0 0 : slabdata 0 0 0 ovl_inode 0 0 672 24 4 : tunables 0 0 0 : slabdata 0 0 0 fuse_request 0 0 152 26 1 : tunables 0 0 0 : slabdata 0 0 0 fuse_inode 0 0 832 19 4 : tunables 0 0 0 : slabdata 0 0 0 jffs2_refblock 0 0 240 17 1 : tunables 0 0 0 : slabdata 0 0 0 jffs2_i 0 0 680 24 4 : tunables 0 0 0 : slabdata 0 0 0 ntfs_big_inode_cache 0 0 896 18 4 : tunables 0 0 0 : slabdata 0 0 0 ntfs_inode_cache 0 0 296 27 2 : tunables 0 0 0 : slabdata 0 0 0 nfs_direct_cache 0 0 192 21 1 : tunables 0 0 0 : slabdata 0 0 0 nfs_read_data 34 34 960 17 4 : tunables 0 0 0 : slabdata 2 2 0 nfs_inode_cache 0 0 1072 30 8 : tunables 0 0 0 : slabdata 0 0 0 isofs_inode_cache 0 0 640 25 4 : tunables 0 0 0 : slabdata 0 0 0 fat_inode_cache 0 0 728 22 4 : tunables 0 0 0 : slabdata 0 0 0 fat_cache 0 0 40 102 1 : tunables 0 0 0 : slabdata 0 0 0 squashfs_inode_cache 0 0 704 23 4 : tunables 0 0 0 : slabdata 0 0 0 jbd2_transaction_s 64 64 256 16 1 : tunables 0 0 0 : slabdata 4 4 0 jbd2_journal_head 612 612 120 34 1 : tunables 0 0 0 : slabdata 18 18 0 jbd2_revoke_table_s 256 256 16 256 1 : tunables 0 0 0 : slabdata 1 1 0 ext4_fc_dentry_update 0 0 80 51 1 : tunables 0 0 0 : slabdata 0 0 0 ext4_inode_cache 4592 4592 1136 28 8 : tunables 0 0 0 : slabdata 164 164 0 ext4_allocation_context 128 128 128 32 1 : tunables 0 0 0 : slabdata 4 4 0 ext4_system_zone 102 102 40 102 1 : tunables 0 0 0 : slabdata 1 1 0 ext4_io_end 256 256 64 64 1 : tunables 0 0 0 : slabdata 4 4 0 ext4_pending_reservation 512 512 32 128 1 : tunables 0 0 0 : slabdata 4 4 0 ext4_extent_status 3876 3876 40 102 1 : tunables 0 0 0 : slabdata 38 38 0 mbcache 292 292 56 73 1 : tunables 0 0 0 : slabdata 4 4 0 kioctx 0 0 576 28 4 : tunables 0 0 0 : slabdata 0 0 0 dio 0 0 640 25 4 : tunables 0 0 0 : slabdata 0 0 0 pid_namespace 0 0 136 30 1 : tunables 0 0 0 : slabdata 0 0 0 rpc_inode_cache 0 0 640 25 4 : tunables 0 0 0 : slabdata 0 0 0 ip4-frags 0 0 200 20 1 : tunables 0 0 0 : slabdata 0 0 0 xfrm_state 21 21 768 21 4 : tunables 0 0 0 : slabdata 1 1 0 ip_dst_cache 84 84 192 21 1 : tunables 0 0 0 : slabdata 4 4 0 RAW 48 48 1024 16 4 : tunables 0 0 0 : slabdata 3 3 0 UDP 112 112 1152 28 8 : tunables 0 0 0 : slabdata 4 4 0 tw_sock_TCP 0 0 240 17 1 : tunables 0 0 0 : slabdata 0 0 0 request_sock_TCP 0 0 304 26 2 : tunables 0 0 0 : slabdata 0 0 0 TCP 42 42 2240 14 8 : tunables 0 0 0 : slabdata 3 3 0 hugetlbfs_inode_cache 54 54 600 27 4 : tunables 0 0 0 : slabdata 2 2 0 eventpoll_pwq 392 392 72 56 1 : tunables 0 0 0 : slabdata 7 7 0 inotify_inode_mark 255 255 80 51 1 : tunables 0 0 0 : slabdata 5 5 0 request_queue 17 17 1832 17 8 : tunables 0 0 0 : slabdata 1 1 0 biovec-max 116 168 4096 8 8 : tunables 0 0 0 : slabdata 21 21 0 biovec-128 48 48 2048 16 8 : tunables 0 0 0 : slabdata 3 3 0 biovec-64 64 64 1024 16 4 : tunables 0 0 0 : slabdata 4 4 0 user_namespace 0 0 536 30 4 : tunables 0 0 0 : slabdata 0 0 0 audit_buffer 170 170 24 170 1 : tunables 0 0 0 : slabdata 1 1 0 sock_inode_cache 646 646 832 19 4 : tunables 0 0 0 : slabdata 34 34 0 skbuff_fclone_cache 32 32 512 16 2 : tunables 0 0 0 : slabdata 2 2 0 skbuff_head_cache 512 512 256 16 1 : tunables 0 0 0 : slabdata 32 32 0 file_lock_cache 68 68 232 17 1 : tunables 0 0 0 : slabdata 4 4 0 file_lock_ctx 292 292 56 73 1 : tunables 0 0 0 : slabdata 4 4 0 fsnotify_mark_connector 512 512 32 128 1 : tunables 0 0 0 : slabdata 4 4 0 net_namespace 16 16 4032 8 8 : tunables 0 0 0 : slabdata 2 2 0 proc_dir_entry 1512 1512 192 21 1 : tunables 0 0 0 : slabdata 72 72 0 pde_opener 408 408 40 102 1 : tunables 0 0 0 : slabdata 4 4 0 proc_inode_cache 4029 4224 664 24 4 : tunables 0 0 0 : slabdata 176 176 0 seq_file 136 136 120 34 1 : tunables 0 0 0 : slabdata 4 4 0 sigqueue 204 204 80 51 1 : tunables 0 0 0 : slabdata 4 4 0 bdev_cache 76 76 832 19 4 : tunables 0 0 0 : slabdata 4 4 0 shmem_inode_cache 1541 1541 688 23 4 : tunables 0 0 0 : slabdata 67 67 0 kernfs_node_cache 36064 36064 128 32 1 : tunables 0 0 0 : slabdata 1127 1127 0 mnt_cache 675 675 320 25 2 : tunables 0 0 0 : slabdata 27 27 0 filp 4893 5536 256 16 1 : tunables 0 0 0 : slabdata 346 346 0 inode_cache 28563 28647 592 27 4 : tunables 0 0 0 : slabdata 1061 1061 0 dentry 41089 41244 192 21 1 : tunables 0 0 0 : slabdata 1964 1964 0 names_cache 48 48 4096 8 8 : tunables 0 0 0 : slabdata 6 6 0 iint_cache 0 0 120 34 1 : tunables 0 0 0 : slabdata 0 0 0 buffer_head 6786 6786 104 39 1 : tunables 0 0 0 : slabdata 174 174 0 uts_namespace 36 36 440 18 2 : tunables 0 0 0 : slabdata 2 2 0 nsproxy 224 224 72 56 1 : tunables 0 0 0 : slabdata 4 4 0 mm_struct 136 136 960 17 4 : tunables 0 0 0 : slabdata 8 8 0 files_cache 161 161 704 23 4 : tunables 0 0 0 : slabdata 7 7 0 signal_cache 677 688 1024 16 4 : tunables 0 0 0 : slabdata 43 43 0 sighand_cache 270 270 2112 15 8 : tunables 0 0 0 : slabdata 18 18 0 task_struct 406 432 3584 9 8 : tunables 0 0 0 : slabdata 48 48 0 cred_jar 16465 18039 192 21 1 : tunables 0 0 0 : slabdata 859 859 0 anon_vma_chain 10216 11200 64 64 1 : tunables 0 0 0 : slabdata 175 175 0 anon_vma 6123 6854 88 46 1 : tunables 0 0 0 : slabdata 149 149 0 pid 768 768 128 32 1 : tunables 0 0 0 : slabdata 24 24 0 trace_event_file 2622 2622 88 46 1 : tunables 0 0 0 : slabdata 57 57 0 ftrace_event_field 5865 5865 48 85 1 : tunables 0 0 0 : slabdata 69 69 0 pool_workqueue 232 336 256 16 1 : tunables 0 0 0 : slabdata 21 21 0 radix_tree_node 4144 4144 584 28 4 : tunables 0 0 0 : slabdata 148 148 0 task_group 0 0 704 23 4 : tunables 0 0 0 : slabdata 0 0 0 vmap_area 2816 2816 64 64 1 : tunables 0 0 0 : slabdata 44 44 0 dma-kmalloc-8k 0 0 8192 4 8 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-4k 0 0 4096 8 8 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-2k 0 0 2048 16 8 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-1k 0 0 1024 16 4 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-512 0 0 512 16 2 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-256 0 0 256 16 1 : tunables 0 0 0 : slabdata 0 0 0 dma-kmalloc-128 0 0 128 32 1 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-8k 0 0 8192 4 8 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-4k 0 0 4096 8 8 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-2k 0 0 2048 16 8 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-1k 0 0 1024 16 4 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-512 0 0 512 16 2 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-256 0 0 256 16 1 : tunables 0 0 0 : slabdata 0 0 0 kmalloc-rcl-128 1152 1152 128 32 1 : tunables 0 0 0 : slabdata 36 36 0 kmalloc-8k 108 108 8192 4 8 : tunables 0 0 0 : slabdata 27 27 0 kmalloc-4k 1042 1072 4096 8 8 : tunables 0 0 0 : slabdata 134 134 0 kmalloc-2k 1000 1072 2048 16 8 : tunables 0 0 0 : slabdata 67 67 0 kmalloc-1k 1487 1552 1024 16 4 : tunables 0 0 0 : slabdata 97 97 0 kmalloc-512 1825 1920 512 16 2 : tunables 0 0 0 : slabdata 120 120 0 kmalloc-256 7441 7584 256 16 1 : tunables 0 0 0 : slabdata 474 474 0 kmalloc-128 41035 41984 128 32 1 : tunables 0 0 0 : slabdata 1312 1312 0 kmem_cache_node 224 224 128 32 1 : tunables 0 0 0 : slabdata 7 7 0 kmem_cache 176 176 256 16 1 : tunables 0 0 0 : slabdata 11 11 0 查看内存是否增加slab unreclaimable如果有增加的话需要看kmalloc里面的统计有没有增加那个增加的多的话就要看一下内核态,主要看num_objs objsize 这两列信息做一个乘积看是否有明显增加。
kmemleak的使用 1、CONFIG_HAVE_DEBUG_KMEMLEAK 所有kmemleak相关config的依赖 2、CONFIG_DEBUG_KMEMLEAK kmemleak功能开关打开后会建立/sys/kernel/debug/kmemleak接口 3、CONFIG_DEBUG_KMEMLEAK_DEFAULT_OFF 此宏打开后kmemleak默认关闭可以通过cmdline中通过kmemleakon打开 4、CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN 支持kmemleak自动扫描可以设置扫描时间间隔默认为600秒关闭则不会自动扫描 5、CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE16000 编译更改从menuconfig/defconfig改了后生成.config
使用时挂载不上或者失败,适当增加CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE
echo scan /sys/kernel/debug/kmemleak
cat /sys/kernel/debug/kmemleak
2小内存时推荐使用slab/slub debug工具
CONFIG_SLUBy CONFIG_SLUB_DEBUGy CONFIG_SLUB_DEBUG_ONy CONFIG_SLUB_STATSy #save the stack CONFIG_STACKDEPOTy 查看slab debug信息统计状态等 /sys/kernel/slab/* 调试内存泄漏踩踏等信息 /sys/kernel/debug/slab/* 如果内存kmalloc128内存比较多就查看alloc-traces cat /sys/kernel/debug/slab/kmalloc-128/alloc_traces 文章转载自: http://www.morning.jzkqg.cn.gov.cn.jzkqg.cn http://www.morning.tqbyw.cn.gov.cn.tqbyw.cn http://www.morning.ghxtk.cn.gov.cn.ghxtk.cn http://www.morning.rqkzh.cn.gov.cn.rqkzh.cn http://www.morning.jfjqs.cn.gov.cn.jfjqs.cn http://www.morning.smmby.cn.gov.cn.smmby.cn http://www.morning.yqwsd.cn.gov.cn.yqwsd.cn http://www.morning.nfqyk.cn.gov.cn.nfqyk.cn http://www.morning.rmyt.cn.gov.cn.rmyt.cn http://www.morning.fdzzh.cn.gov.cn.fdzzh.cn http://www.morning.gwmjy.cn.gov.cn.gwmjy.cn http://www.morning.krdxz.cn.gov.cn.krdxz.cn http://www.morning.rmltt.cn.gov.cn.rmltt.cn http://www.morning.nxhjg.cn.gov.cn.nxhjg.cn http://www.morning.wjlkz.cn.gov.cn.wjlkz.cn http://www.morning.rmpkn.cn.gov.cn.rmpkn.cn http://www.morning.rxkq.cn.gov.cn.rxkq.cn http://www.morning.rckmz.cn.gov.cn.rckmz.cn http://www.morning.hlfgm.cn.gov.cn.hlfgm.cn http://www.morning.cjxqx.cn.gov.cn.cjxqx.cn http://www.morning.kbynw.cn.gov.cn.kbynw.cn http://www.morning.fqssx.cn.gov.cn.fqssx.cn http://www.morning.ssmhn.cn.gov.cn.ssmhn.cn http://www.morning.rcjqgy.com.gov.cn.rcjqgy.com http://www.morning.gqcd.cn.gov.cn.gqcd.cn http://www.morning.nbsfb.cn.gov.cn.nbsfb.cn http://www.morning.nlgnk.cn.gov.cn.nlgnk.cn http://www.morning.gqfks.cn.gov.cn.gqfks.cn http://www.morning.rdlrm.cn.gov.cn.rdlrm.cn http://www.morning.kntsd.cn.gov.cn.kntsd.cn http://www.morning.zxhhy.cn.gov.cn.zxhhy.cn http://www.morning.xbzfz.cn.gov.cn.xbzfz.cn http://www.morning.spsqr.cn.gov.cn.spsqr.cn http://www.morning.kjksn.cn.gov.cn.kjksn.cn http://www.morning.drfrm.cn.gov.cn.drfrm.cn http://www.morning.gnwpg.cn.gov.cn.gnwpg.cn http://www.morning.rfqk.cn.gov.cn.rfqk.cn http://www.morning.zkqjz.cn.gov.cn.zkqjz.cn http://www.morning.zlsmx.cn.gov.cn.zlsmx.cn http://www.morning.gqryh.cn.gov.cn.gqryh.cn http://www.morning.hsdhr.cn.gov.cn.hsdhr.cn http://www.morning.qfwzm.cn.gov.cn.qfwzm.cn http://www.morning.chgmm.cn.gov.cn.chgmm.cn http://www.morning.lhxdq.cn.gov.cn.lhxdq.cn http://www.morning.lpqgq.cn.gov.cn.lpqgq.cn http://www.morning.cgbgc.cn.gov.cn.cgbgc.cn http://www.morning.brjq.cn.gov.cn.brjq.cn http://www.morning.ynbyk.cn.gov.cn.ynbyk.cn http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn http://www.morning.rxrw.cn.gov.cn.rxrw.cn http://www.morning.drswd.cn.gov.cn.drswd.cn http://www.morning.dncgb.cn.gov.cn.dncgb.cn http://www.morning.hgwsj.cn.gov.cn.hgwsj.cn http://www.morning.wsnbg.cn.gov.cn.wsnbg.cn http://www.morning.rfqk.cn.gov.cn.rfqk.cn http://www.morning.xmrmk.cn.gov.cn.xmrmk.cn http://www.morning.xprq.cn.gov.cn.xprq.cn http://www.morning.rhsg.cn.gov.cn.rhsg.cn http://www.morning.cgthq.cn.gov.cn.cgthq.cn http://www.morning.lgsfb.cn.gov.cn.lgsfb.cn http://www.morning.mxnrl.cn.gov.cn.mxnrl.cn http://www.morning.8yitong.com.gov.cn.8yitong.com http://www.morning.fnkcg.cn.gov.cn.fnkcg.cn http://www.morning.ldgqh.cn.gov.cn.ldgqh.cn http://www.morning.qmwzz.cn.gov.cn.qmwzz.cn http://www.morning.jqbmj.cn.gov.cn.jqbmj.cn http://www.morning.sacxbs.cn.gov.cn.sacxbs.cn http://www.morning.zfhzx.cn.gov.cn.zfhzx.cn http://www.morning.khzml.cn.gov.cn.khzml.cn http://www.morning.wmyqw.com.gov.cn.wmyqw.com http://www.morning.ygxf.cn.gov.cn.ygxf.cn http://www.morning.djxnw.cn.gov.cn.djxnw.cn http://www.morning.bhwll.cn.gov.cn.bhwll.cn http://www.morning.zmlbq.cn.gov.cn.zmlbq.cn http://www.morning.fjntg.cn.gov.cn.fjntg.cn http://www.morning.yrycb.cn.gov.cn.yrycb.cn http://www.morning.rlpmy.cn.gov.cn.rlpmy.cn http://www.morning.rtspr.cn.gov.cn.rtspr.cn http://www.morning.gcdzp.cn.gov.cn.gcdzp.cn http://www.morning.rykx.cn.gov.cn.rykx.cn