0

I am trying to monitor memory usage of a process with both Valgrind and pmap.

Since the process is not run by itself but through Valgrind, is it safe to say that monitoring Valgrind with pmap would be the same as monitoring the process, or does Valgrind use additional memory?

Thanks.

O.B.
  • 29
  • 1
  • 7

2 Answers2

0

Depending on the tool, valgrind can use a lot more memory than a native run. Even the "none" tool uses more memory.

Various valgrind tools can do a detailed monitoring/reporting of the memory used by your application.

You might e.g. use the memcheck tool with --xtree-memory=full and visualise the resulting file with kcachegrind. See e.g. https://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree for more details.

The massif tool can be used to report peaks of memory usages.

phd
  • 3,669
  • 1
  • 11
  • 12
0

Just to add a few more details. When running under Valgrind, you will have

  • two stacks, one for the Valgrind host, one for the guest application
  • two 'text segments' mapped into memory (that's the machine code from the binaries of the host and the client + client shared libraries)
  • other stuff like data segments

In addition, each tool will use memory for whatever tracking it is doing, as @phd already mentioned. So for example memcheck will allocate 'shadow' memory so that it can tell when the client uses uninitialized memory.

Finally, if you run Valgrind with debug output (-d), it will print its own "address space manager" map, which is similar to pmap -x.

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43