4

I am investigating memory usage of a process that (unexpectedly) reserves terabytes of VIRT. If I do pmap for that process, I can see some beefy allocation, e.g.:

00007f39ea671000 317288696K rw---   [ anon ]

I am running my process under strace tracing all memory related syscalls and priting their stracktraces.

strace -o ~/strace.out -f -e trace=mremap,mmap,munmap,brk -k <command>

I would expect that I would be able to find this allocation in strace.out, so I grep it:

cat strace.out | grep -A10 7f39ea671000

and I only see this call to mmap:

106224 mmap(NULL, 201543680, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f39ea671000
 > /usr/lib/x86_64-linux-gnu/libc-2.29.so(mmap64+0x22) [0xf5252]
 > /usr/lib/x86_64-linux-gnu/libc-2.29.so(_IO_str_seekoff+0x2ff4) [0x84ab4]
 > /usr/lib/x86_64-linux-gnu/libc-2.29.so(_IO_str_seekoff+0x3e0b) [0x858cb]
 > /usr/lib/x86_64-linux-gnu/libc-2.29.so(__libc_malloc+0x22f) [0x869ff]
...

What is happening here? Does pmap shows exaggerated size of the mapping? Or do I miss some syscalls?

pepyakin
  • 2,217
  • 19
  • 31
  • Is `pmap` able to tell a contiguous memory address range allocated in a single call from the same address range allocated via several back-to-back calls? – hidefromkgb Nov 25 '19 at 22:17
  • Good question @hidefromkgb and I don't know! I assumed that there is some coalescing of the memory regions going on but I haven't found any evidence for that. – pepyakin Nov 26 '19 at 15:58

0 Answers0