linux内存泄露定位过程(kmemleak和slab debug)
1,当遇到内存增加过多时,或者由于内存导致系统oom时我们怎么定位呢,定位时需要确认是内核态还是用户态内存泄露。
排查步骤
top查看VIRT和RES内存
root@ubuntu2004:~# 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 MemPID 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+
shirft+M 可以排序查看内存的排序。
2,ps -aux
root@ubuntu2004:~# 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
root@ubuntu2004:~# 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表示的是VSS,VmRSS表示的是RSS;
查看所有进程的累加
root@ubuntu2004:~# cat /proc/624/smaps | grep 'Rss' | awk '{Total+=$2} END {print Total"KB"}'
107248KB
root@ubuntu2004:~# cat /proc/624/smaps | grep 'Pss' | awk '{Total+=$2} END {print Total"KB"}'
77434KB
查看vss和res物理内存有没有增加,如果有明显增加可以确定是用户态的内存泄漏,可以使用valgrind来定位问题。
如果用户态内存没看到有明显增加,就需要考虑是不是内核态的泄露了。
首先通过cat proc/meminfo来查看unReclamiable slab memory有没有明显变化。
root@ubuntu2004:~# 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的内存没有明显变化,如果有的话就可以确认是内核态的泄露。
root@ubuntu2004:~# 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中通过kmemleak=on打开
4、CONFIG_DEBUG_KMEMLEAK_AUTO_SCAN
支持kmemleak自动扫描,可以设置扫描时间间隔,默认为600秒,关闭则不会自动扫描
5、CONFIG_DEBUG_KMEMLEAK_MEM_POOL_SIZE=16000
编译更改,从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_SLUB=y
CONFIG_SLUB_DEBUG=y
CONFIG_SLUB_DEBUG_ON=y
CONFIG_SLUB_STATS=y
#save the stack
CONFIG_STACKDEPOT=y
查看slab debug信息,统计状态等
/sys/kernel/slab/*
调试内存泄漏,踩踏等信息
/sys/kernel/debug/slab/*
如果内存kmalloc=128内存比较多,就查看alloc-traces
cat /sys/kernel/debug/slab/kmalloc-128/alloc_traces
相关文章:
![](https://www.ngui.cc/images/no-images.jpg)
linux内存泄露定位过程(kmemleak和slab debug)
1,当遇到内存增加过多时,或者由于内存导致系统oom时我们怎么定位呢,定位时需要确认是内核态还是用户态内存泄露。 排查步骤 top查看VIRT和RES内存 rootubuntu2004:~# top top - 21:05:39 up 7 min, 1 user, load average: 5.01, 4.09, 2.…...
![](https://www.ngui.cc/images/no-images.jpg)
2025年安卓面试复习总结
文章目录 深入理解并熟练运用常用设计模式及反射原理,能够自定义注解及泛型,多次通过设计模式对 app 代码进行高效重构,显著提升代码的可维护性与扩展性。设计模式自定义注解泛型Kotlin泛型 精通多线程原理,对 ThreadPoolExecutor…...
![](https://www.ngui.cc/images/no-images.jpg)
JS scrollIntoView 技巧揭秘:解锁网页流畅交互
文章目录 一.基本概念二.语法和参数基本语法:element.scrollIntoView();参数详解: 三.应用场景和示例场景一:点击目录点位到相应的位置React 示例代码:Vue3 示例代码: 场景二:轮播图定位到指定图片示例代码…...
![](https://www.ngui.cc/images/no-images.jpg)
【Ubuntu 24.04】常见问题解决
1.24开启3D加速黑屏 参考文章:Ubuntu24开机黑屏,VMware卡死,虚拟机繁忙解决方案 没有3D加速就没有动画,所以我们需要开启3D加速,但是直接开启3D加速会黑屏 由于Ubuntu24内部的图形加速驱动异常,因此需要更新…...
![](https://www.ngui.cc/images/no-images.jpg)
前端依赖安装指南
前端依赖安装指南 一、NVM管理工具安装 1.在 Windows 上安装 下载 NVM for Windows 的安装程序:(最新版本可以在 nvm-windows Releases 页面 找到)运行下载的安装程序并按步骤操作。 2.配置 NVM exe安装自动配置环境变量 3. 验证 NVM 安装 验证 NVM 是否成功…...
![](https://i-blog.csdnimg.cn/direct/54a4bf1b13be4464a2a84285c38a35ff.png)
灌区闸门自动化控制系统-精准渠道量测水-灌区现代化建设
项目背景 本项目聚焦于黑龙江某一灌区的现代化改造工程,该灌区覆盖广阔,灌溉面积高达7.5万亩,地域上跨越6个乡镇及涵盖17个村庄。项目核心在于通过全面的信息化建设,强力推动节水灌溉措施的实施,旨在显著提升农业用水的…...
![](https://csdnimg.cn/release/blog_editor_html/release2.3.7/ckeditor/plugins/CsdnLink/icons/icon-default.png?t=O83A)
ELK实战(最详细)
一、什么是ELK ELK是三个产品的简称:ElasticSearch(简称ES) 、Logstash 、Kibana 。其中: ElasticSearch:是一个开源分布式搜索引擎Logstash :是一个数据收集引擎,支持日志搜集、分析、过滤,支持大量数据…...
![](https://www.ngui.cc/images/no-images.jpg)
《大型语言模型与强化学习的融合:探索问题的新解决方案与开源验证需求》
强化学习在2020年代初期通过开源项目如CleanRL的多学习者PPO算法取得了显著进展,但在语言模型领域未能充分利用其潜力 1. 开源项目CleanRL的贡献 CleanRL 是一个致力于提供简单、高效且易于理解的强化学习(RL)算法实现的开源项目。该项目通…...
![](https://i-blog.csdnimg.cn/direct/8696b98e2db342ccb950e25be9423cb4.png)
springboot 默认的 mysql 驱动版本
本案例以 springboot 3.1.12 版本为例 <parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>3.1.12</version><relativePath/> </parent> 点击 spring-…...
![](https://www.ngui.cc/images/no-images.jpg)
10分钟快速了解OceanGPT(沧渊)
10分钟快速了解OceanGPT(沧渊) 海洋科学任务的大语言模型——OceanGPT OceanGPT是如何训练的?为了训练 OceanGPT (沧渊) ,收集了一个跨越多个领域的海洋科学语料库。由于每个子领域和主题都有其独特的数据特征和模式,因此提出了一个特定于领域的指令生成框架,称为 DoDirec…...
![](https://i-blog.csdnimg.cn/direct/aa0d9afbb2ac4d758bb31ea6e598cf82.png)
蓝桥杯嵌入式速通(1)
1.工程准备 创建一文件夹存放自己的代码,并在mdk中include上文件夹地址 把所有自身代码的头文件都放在headfile头文件中,之后只需要在新的文件中引用headfile即可 headfile中先提前可加入 #include "stdio.h" #include "string.h"…...
![](https://www.ngui.cc/images/no-images.jpg)
Redis优化建议详解
Redis优化建议详解 1. 内存优化 1.1 内存配置 设置最大内存 maxmemory 4gb 内存淘汰策略 maxmemory-policy allkeys-lru 样本数量 maxmemory-samples 51.2 内存优化策略 数据结构优化 使用压缩列表(ziplist)合理设置hash-max-ziplist-entries使用整数…...
![](https://www.ngui.cc/images/no-images.jpg)
ceph 存储 full 阈值调整
前言 在 Ceph 集群中,默认情况下,当某些 OSD(对象存储守护进程)的使用率达到 85% 时,系统会发出 nearfull 警告,并可能限制进一步的写入操作,以防止数据丢失或集群不稳定。 要允许在 OSD 使用率超过 85% 的情况下继续写入,您可以调整以下两个参数: mon_osd_nearful…...
![](https://i-blog.csdnimg.cn/img_convert/59bea1a3ccc60490144f3d477164b2b3.png)
后端技术选型 sa-token校验学习 下 结合项目学习 后端鉴权
目录 后端注册拦截器 实现对 WebMvcConfigurer 接口的类实现 静态变量 方法重写 注册 Spring Framework拦截器 Sa-Token中SaServletFilter拦截器 思考 为什么使用两个拦截器 1. Spring Framework 拦截器 2. SaServletFilter 为什么要注册两个拦截器? 总结 …...
![](https://www.ngui.cc/images/no-images.jpg)
Vue.js组件开发-实现组件切换效果的两种方法 条件渲染、动态组件
在Vue.js中,实现组件切换效果通常依赖于条件渲染或动态组件。 方法一:条件渲染 条件渲染使用v-if、v-else-if和v-else指令来根据条件展示或隐藏组件。这种方法适用于需要在不同条件下展示不同组件的场景。 <template><div><button cli…...
![](https://i-blog.csdnimg.cn/direct/e513539702b5440ca45bf548bd73442d.png#pic_center)
primitive 的 Appearance编写着色器材质
import { nextTick, onMounted, ref } from vue import * as Cesium from cesium import gsap from gsaponMounted(() > { ... })// 1、创建矩形几何体,Cesium.RectangleGeometry:几何体,Rectangle:矩形 let rectGeometry new…...
![](https://i-blog.csdnimg.cn/direct/18fba90f495845618d4912983efcf355.png)
Seata搭建
1.初识Seata Quick Start | Apache Seata 官网 2.准备nacos和 seata 启动nacos startup.cmd -m standalone账号nacos 密码nacos 搭建seata TC 这里下载的 1.4.2 seata-server-1.4.2 1.修改seata配置文件 registry.conf 这里我们使用nacos作为注册中心 和 配置中心 r…...
![](https://i-blog.csdnimg.cn/direct/9fc51a624613444baee53c372339f297.png#pic_center)
流浪猫流浪狗领养PHP网站源码
源码介绍 流浪猫流浪狗领养PHP网站源码,适合做猫狗宠物类的发信息发布。当然其他信息发布也是可以的。 导入数据库,修改数据库配置/application/database.php 设置TP伪静态,设置运行目录, 后台:/abcd.php/dashboard?…...
![](https://www.ngui.cc/images/no-images.jpg)
asammdf python 处理MF4文件库简介
asammdf 是一个功能强大的 Python 库,专门用于处理汽车行业常用的 MDF(Measured Data Format)文件。以下是 asammdf 的主要功能总结: 主要功能 读取和写入 MDF 文件: 支持 MDF 文件的版本 3.x 和 4.x。 能够读取和…...
![](https://www.ngui.cc/images/no-images.jpg)
【“软件工程”基础概念学习】
基础和相关概念 英文:Software Engineering 软:物体内部的组织疏松,受外力作用后容易改变形状软件: 计算机系统的组成部分,是指挥计算机进行计算、判断、处理信息的程序系统。通常分为系统软件和应用软件。借指某项活…...
![](https://i-blog.csdnimg.cn/img_convert/9c6b055b9def98019bad5a8a79c24a2a.png)
省森林防火应急指挥系统
森林防火形势严峻 我国森林防火形势十分严峻,森林火灾具有季节性强、发现难、成灾迅速等特点,且扑救难度大、影响范围广、造成的损失重。因此,构建森林防火应急指挥系统显得尤为重要。 系统建设模式与架构 森林防火应急指挥系统采用大智慧…...
![](https://www.ngui.cc/images/no-images.jpg)
一键整理背包界面功能
一键整理功能 游戏《帕鲁》中的背包界面有一键整理的功能,就是玩家随意拖拽背包格子里的物品,然后导致背包界面看起来很凌乱,比如物品a在一个格子里数量为1,另一个格子里数量为3,或者还有空格杂夹在有物品的格子旁边,一键排序功能可以解决这个问题,(将相同物品整合到一…...
![](https://i-blog.csdnimg.cn/img_convert/e6fc2e8f033b9f47295d2341822c38c3.jpeg)
给DevOps加点料:融入安全性的DevSecOps
从前,安全防护只是特定团队的责任,在开发的最后阶段才会介入。当开发周期长达数月、甚至数年时,这样做没什么问题;但是现在,这种做法现在已经行不通了。 采用 DevOps 可以有效推进快速频繁的开发周期(有时…...
![](https://www.ngui.cc/images/no-images.jpg)
uniapp 使用 pinia 状态持久化
1.创建文件 stores -index.js -global.js2.对应文件内容 index.js 安装插件 npm i pinia-plugin-persistedstate import { createPinia } from pinia; import persist from pinia-plugin-persistedstate; const pinia createPinia(); pinia.use(persist); export default pi…...
![](https://www.ngui.cc/images/no-images.jpg)
HarmonyOS鸿蒙-@State@Prop装饰器限制条件
一、组件Components级别的状态管理: State组件内状态限制条件 1.State装饰的变量必须初始化,否则编译期会报错。 // 错误写法,编译报错 State count: number;// 正确写法 State count: number 10; 2.嵌套属性的赋值观察不到。 // 嵌套的…...
![](https://i-blog.csdnimg.cn/direct/c9d72f3099284e8692ae72a88841286d.gif)
Java Web开发进阶——Spring Boot与Spring Data JPA
Spring Data JPA 是 Spring 提供的一种面向数据访问的持久化框架,它简化了 JPA 的实现,为开发者提供了一种快速操作数据库的方式。在结合 Spring Boot 使用时,开发者能够快速完成数据库访问层的开发。 1. 介绍Spring Data JPA 1.1 什么是Spr…...
![](https://i-blog.csdnimg.cn/direct/a407222a7b6b4ec982230805e670a5f8.png)
Vue Router4
Vue Router 是 Vue.js 官方的路由管理器。Vue Router 基于路由和组件的映射关系,监听页面路径的变化,渲染对应的组件。 安装: npm install vue-router。 基本使用: // src/router/index.js import {createRouter, createWebHa…...
![](https://www.ngui.cc/images/no-images.jpg)
计算机网络之---应用层协议概述
应用层协议概述 应用层协议是OSI模型中的第7层(应用层)定义的一组规则,用于支持和管理不同应用程序之间的通信。应用层协议定义了数据交换的格式、规则和约定,使得不同的系统或应用能够互相理解并正确地交换数据。它直接面向用户并…...
![](https://www.ngui.cc/images/no-images.jpg)
html + css 顶部滚动通知栏示例
前言 在现代网页设计中,一个吸引人的顶部滚动通知栏不仅能够有效传达重要信息,还能提升用户体验。通过使用HTML和CSS,我们可以创建既美观又功能强大的组件,这些组件可以在不影响网站整体性能的情况下提供实时更新或紧急通知。 本…...
![](https://i-blog.csdnimg.cn/direct/c3b136c8cc67455eb1ec02b4d8fb2b0e.png)
【Rust自学】11.6. 控制测试运行:并行和串行(连续执行)测试
喜欢的话别忘了点赞、收藏加关注哦,对接下来的教程有兴趣的可以关注专栏。谢谢喵!(・ω・) 11.6.1. 控制测试的运行方式 cargo test和cargo run一样,cargo test也会编译代码并生成一个二进制文件用于测试,…...
![](/images/no-images.jpg)
做网站的dreamweaver/广州外贸推广
本文经过作者亲自测试,如有问题或者更好的解决方案,还望各位指出纠正。 原因: 因为word有自动检查错误的功能,就算关闭了自动检查的功能,只要稍微改动就有报上边的错误。 最佳解决方案: 在记事本上写好对应…...
![](/images/no-images.jpg)
优质做网站公司/bt磁力搜索引擎
在bitbucket上使用https协议,经常会在提交代码的时候出错,让人很着急上火,但是用ssh就要方便很多。下面介绍一下设置ssh的方法:1.在终端中运行ssh-keygen。2.然后一路enter,直接到结束。不要理会中间的输入。3 打开用户…...
![](/images/no-images.jpg)
织梦云建站系统/宁波品牌网站推广优化公司
[20160831]关于数据块Checksum.txt --以前我学习bbed时做过一些测试,将AAAA替换成BBBB,你可以发现数据块的Checksum并没有发生变化,当时并没有仔细探究, --现在想起来计算Checksum算法应该相对简单,就是做异或操作. --比如上面的字符AAAA如果2个字符按位做异或操作,变成0000000…...
![](http://images.cnitblog.com/blog/360778/201402/271056422044524.jpg)
吉林电商网站建设/百度推广费
按照http://blog.csdn.net/azkabannull/article/details/7872958中的方法,在cygwin中运行runbundler.sh; 按照http://oliver.zheng.blog.163.com/blog/static/1424115952011915113138431/中的方法,使用Bundle2PMVS.exe和prep_pmvs.sh&#x…...
![](https://static.leiphone.com/uploads/new/article/740_740/201612/5854f3549c7fd.jpg?imageMogr2/format/jpg/quality/90)
做外贸哪个网站比较好/搜索排名广告营销怎么做
雷锋网(公众号:雷锋网)按:数据科学、大数据和物联网正在以令人炫目的速度发展和演进,而商业界正以缓慢的速度将更多来自不同渠道的数据整合起来,并能从中洞察更多信息。本文是 Andrew Dipper 对数据科学行业2017年的展望ÿ…...
![](/images/no-images.jpg)
常见网站安全漏洞/seo工具在线访问
neo4j-w3cschool教程 neo4j初次使用学习简单操作-cypher语言使用...