![如何找到创建匿名私有内存映射区域的代码部分](https://linux22.com/image/110338/%E5%A6%82%E4%BD%95%E6%89%BE%E5%88%B0%E5%88%9B%E5%BB%BA%E5%8C%BF%E5%90%8D%E7%A7%81%E6%9C%89%E5%86%85%E5%AD%98%E6%98%A0%E5%B0%84%E5%8C%BA%E5%9F%9F%E7%9A%84%E4%BB%A3%E7%A0%81%E9%83%A8%E5%88%86.png)
我正在分析/proc/pid/smaps
C++ 进程的输出,发现大量私有内存映射区域。内存映射区域的数量根据流量不断增长。
有没有办法可以跟踪代码的哪一部分创建了内存块?我尝试过strace -p <pid>
,但在创建堆栈时无法访问堆栈。
00-7fcea0000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65520 kB
Pss: 65520 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65520 kB
Referenced: 65520 kB
Anonymous: 65520 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me nr sd
7fcea4000000-7fcea8000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65516 kB
Pss: 65516 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65516 kB
Referenced: 65516 kB
Anonymous: 65516 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me nr sd
7fceac000000-7fceb0000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65524 kB
Pss: 65524 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65524 kB
Referenced: 65524 kB
Anonymous: 65524 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
7fceb4000000-7fceb8000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65528 kB
Pss: 65528 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65528 kB
Referenced: 65528 kB
Anonymous: 65528 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me nr sd
7fcebc000000-7fcec0000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65516 kB
Pss: 65516 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65516 kB
Referenced: 65516 kB
Anonymous: 65516 kB
AnonHugePages: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd wr mr mw me nr sd
7fcec4000000-7fcec8000000 rw-p 00000000 00:00 0
Size: 65536 kB
Rss: 65504 kB
Pss: 65504 kB
Shared_Clean: 0 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 65504 kB
Referenced: 65504 kB
Anonymous: 65504 kB
AnonHugePages: 0 kB
Swap: 0 kB
332,20 2%