Ziqi Liu
Ziqi Liu

Reputation: 3171

Valgrind Massif take snapshot manually in a programatic way

I'm using Valgrind Massif to measure the memory usage of my program. Actually I know where I allocate or release memory(roughly), so I want to manually take snapshots. Moreover, I want to compare the result from multiple runs, so manually taking snapshots makes more sense in comparison.

Is there a programmatic way to do this?

Upvotes: 0

Views: 527

Answers (1)

phd
phd

Reputation: 3807

You can instruct massif to take a snapshot using massif monitor commands.

See https://www.valgrind.org/docs/manual/ms-manual.html#ms-manual.monitor-commands

Such monitor commands can be done from a shell, using vgdb or from within your program, using the client request VALGRIND_MONITOR_COMMAND.

See https://www.valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.clientreq

Note that if you have a specific client request corresponding to a monitor command, it is better to use the specific client request rather than the 'generic' VALGRIND_MONITOR_COMMAND.

In the case of massif, there are no specific client requests.

Upvotes: 4

Related Questions