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
相关文章:
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.…...
2025年安卓面试复习总结
文章目录 深入理解并熟练运用常用设计模式及反射原理,能够自定义注解及泛型,多次通过设计模式对 app 代码进行高效重构,显著提升代码的可维护性与扩展性。设计模式自定义注解泛型Kotlin泛型 精通多线程原理,对 ThreadPoolExecutor…...
JS scrollIntoView 技巧揭秘:解锁网页流畅交互
文章目录 一.基本概念二.语法和参数基本语法:element.scrollIntoView();参数详解: 三.应用场景和示例场景一:点击目录点位到相应的位置React 示例代码:Vue3 示例代码: 场景二:轮播图定位到指定图片示例代码…...
【Ubuntu 24.04】常见问题解决
1.24开启3D加速黑屏 参考文章:Ubuntu24开机黑屏,VMware卡死,虚拟机繁忙解决方案 没有3D加速就没有动画,所以我们需要开启3D加速,但是直接开启3D加速会黑屏 由于Ubuntu24内部的图形加速驱动异常,因此需要更新…...
前端依赖安装指南
前端依赖安装指南 一、NVM管理工具安装 1.在 Windows 上安装 下载 NVM for Windows 的安装程序:(最新版本可以在 nvm-windows Releases 页面 找到)运行下载的安装程序并按步骤操作。 2.配置 NVM exe安装自动配置环境变量 3. 验证 NVM 安装 验证 NVM 是否成功…...
灌区闸门自动化控制系统-精准渠道量测水-灌区现代化建设
项目背景 本项目聚焦于黑龙江某一灌区的现代化改造工程,该灌区覆盖广阔,灌溉面积高达7.5万亩,地域上跨越6个乡镇及涵盖17个村庄。项目核心在于通过全面的信息化建设,强力推动节水灌溉措施的实施,旨在显著提升农业用水的…...
ELK实战(最详细)
一、什么是ELK ELK是三个产品的简称:ElasticSearch(简称ES) 、Logstash 、Kibana 。其中: ElasticSearch:是一个开源分布式搜索引擎Logstash :是一个数据收集引擎,支持日志搜集、分析、过滤,支持大量数据…...
《大型语言模型与强化学习的融合:探索问题的新解决方案与开源验证需求》
强化学习在2020年代初期通过开源项目如CleanRL的多学习者PPO算法取得了显著进展,但在语言模型领域未能充分利用其潜力 1. 开源项目CleanRL的贡献 CleanRL 是一个致力于提供简单、高效且易于理解的强化学习(RL)算法实现的开源项目。该项目通…...
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-…...
10分钟快速了解OceanGPT(沧渊)
10分钟快速了解OceanGPT(沧渊) 海洋科学任务的大语言模型——OceanGPT OceanGPT是如何训练的?为了训练 OceanGPT (沧渊) ,收集了一个跨越多个领域的海洋科学语料库。由于每个子领域和主题都有其独特的数据特征和模式,因此提出了一个特定于领域的指令生成框架,称为 DoDirec…...
蓝桥杯嵌入式速通(1)
1.工程准备 创建一文件夹存放自己的代码,并在mdk中include上文件夹地址 把所有自身代码的头文件都放在headfile头文件中,之后只需要在新的文件中引用headfile即可 headfile中先提前可加入 #include "stdio.h" #include "string.h"…...
Redis优化建议详解
Redis优化建议详解 1. 内存优化 1.1 内存配置 设置最大内存 maxmemory 4gb 内存淘汰策略 maxmemory-policy allkeys-lru 样本数量 maxmemory-samples 51.2 内存优化策略 数据结构优化 使用压缩列表(ziplist)合理设置hash-max-ziplist-entries使用整数…...
ceph 存储 full 阈值调整
前言 在 Ceph 集群中,默认情况下,当某些 OSD(对象存储守护进程)的使用率达到 85% 时,系统会发出 nearfull 警告,并可能限制进一步的写入操作,以防止数据丢失或集群不稳定。 要允许在 OSD 使用率超过 85% 的情况下继续写入,您可以调整以下两个参数: mon_osd_nearful…...
后端技术选型 sa-token校验学习 下 结合项目学习 后端鉴权
目录 后端注册拦截器 实现对 WebMvcConfigurer 接口的类实现 静态变量 方法重写 注册 Spring Framework拦截器 Sa-Token中SaServletFilter拦截器 思考 为什么使用两个拦截器 1. Spring Framework 拦截器 2. SaServletFilter 为什么要注册两个拦截器? 总结 …...
Vue.js组件开发-实现组件切换效果的两种方法 条件渲染、动态组件
在Vue.js中,实现组件切换效果通常依赖于条件渲染或动态组件。 方法一:条件渲染 条件渲染使用v-if、v-else-if和v-else指令来根据条件展示或隐藏组件。这种方法适用于需要在不同条件下展示不同组件的场景。 <template><div><button cli…...
primitive 的 Appearance编写着色器材质
import { nextTick, onMounted, ref } from vue import * as Cesium from cesium import gsap from gsaponMounted(() > { ... })// 1、创建矩形几何体,Cesium.RectangleGeometry:几何体,Rectangle:矩形 let rectGeometry new…...
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…...
流浪猫流浪狗领养PHP网站源码
源码介绍 流浪猫流浪狗领养PHP网站源码,适合做猫狗宠物类的发信息发布。当然其他信息发布也是可以的。 导入数据库,修改数据库配置/application/database.php 设置TP伪静态,设置运行目录, 后台:/abcd.php/dashboard?…...
asammdf python 处理MF4文件库简介
asammdf 是一个功能强大的 Python 库,专门用于处理汽车行业常用的 MDF(Measured Data Format)文件。以下是 asammdf 的主要功能总结: 主要功能 读取和写入 MDF 文件: 支持 MDF 文件的版本 3.x 和 4.x。 能够读取和…...
【“软件工程”基础概念学习】
基础和相关概念 英文:Software Engineering 软:物体内部的组织疏松,受外力作用后容易改变形状软件: 计算机系统的组成部分,是指挥计算机进行计算、判断、处理信息的程序系统。通常分为系统软件和应用软件。借指某项活…...
VB.net复制Ntag213卡写入UID
本示例使用的发卡器:https://item.taobao.com/item.htm?ftt&id615391857885 一、读取旧Ntag卡的UID和数据 Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click轻松读卡技术支持:网站:Dim i, j As IntegerDim cardidhex, …...
Unity3D中Gfx.WaitForPresent优化方案
前言 在Unity中,Gfx.WaitForPresent占用CPU过高通常表示主线程在等待GPU完成渲染(即CPU被阻塞),这表明存在GPU瓶颈或垂直同步/帧率设置问题。以下是系统的优化方案: 对惹,这里有一个游戏开发交流小组&…...
中南大学无人机智能体的全面评估!BEDI:用于评估无人机上具身智能体的综合性基准测试
作者:Mingning Guo, Mengwei Wu, Jiarun He, Shaoxian Li, Haifeng Li, Chao Tao单位:中南大学地球科学与信息物理学院论文标题:BEDI: A Comprehensive Benchmark for Evaluating Embodied Agents on UAVs论文链接:https://arxiv.…...
USB Over IP专用硬件的5个特点
USB over IP技术通过将USB协议数据封装在标准TCP/IP网络数据包中,从根本上改变了USB连接。这允许客户端通过局域网或广域网远程访问和控制物理连接到服务器的USB设备(如专用硬件设备),从而消除了直接物理连接的需要。USB over IP的…...
rnn判断string中第一次出现a的下标
# coding:utf8 import torch import torch.nn as nn import numpy as np import random import json""" 基于pytorch的网络编写 实现一个RNN网络完成多分类任务 判断字符 a 第一次出现在字符串中的位置 """class TorchModel(nn.Module):def __in…...
AI病理诊断七剑下天山,医疗未来触手可及
一、病理诊断困局:刀尖上的医学艺术 1.1 金标准背后的隐痛 病理诊断被誉为"诊断的诊断",医生需通过显微镜观察组织切片,在细胞迷宫中捕捉癌变信号。某省病理质控报告显示,基层医院误诊率达12%-15%,专家会诊…...
A2A JS SDK 完整教程:快速入门指南
目录 什么是 A2A JS SDK?A2A JS 安装与设置A2A JS 核心概念创建你的第一个 A2A JS 代理A2A JS 服务端开发A2A JS 客户端使用A2A JS 高级特性A2A JS 最佳实践A2A JS 故障排除 什么是 A2A JS SDK? A2A JS SDK 是一个专为 JavaScript/TypeScript 开发者设计的强大库ÿ…...
Kubernetes 网络模型深度解析:Pod IP 与 Service 的负载均衡机制,Service到底是什么?
Pod IP 的本质与特性 Pod IP 的定位 纯端点地址:Pod IP 是分配给 Pod 网络命名空间的真实 IP 地址(如 10.244.1.2)无特殊名称:在 Kubernetes 中,它通常被称为 “Pod IP” 或 “容器 IP”生命周期:与 Pod …...
Elastic 获得 AWS 教育 ISV 合作伙伴资质,进一步增强教育解决方案产品组合
作者:来自 Elastic Udayasimha Theepireddy (Uday), Brian Bergholm, Marianna Jonsdottir 通过搜索 AI 和云创新推动教育领域的数字化转型。 我们非常高兴地宣布,Elastic 已获得 AWS 教育 ISV 合作伙伴资质。这一重要认证表明,Elastic 作为 …...
针对药品仓库的效期管理问题,如何利用WMS系统“破局”
案例: 某医药分销企业,主要经营各类药品的批发与零售。由于药品的特殊性,效期管理至关重要,但该企业一直面临效期问题的困扰。在未使用WMS系统之前,其药品入库、存储、出库等环节的效期管理主要依赖人工记录与检查。库…...
