valgrind 3.13 supported xtree http://valgrind.org/docs/manual/dist.news.html
I used it with massif
valgrind --tool=massif --xtree-memory=full --xtree-memory-file=xtmemory.ms.%p
Then it generated a 16G file. It is too large to load by massif visualizer.. What is the best practice to use xtree-memory
The massif report contains non detailed snapshots, and some detailed snapshots. The detailed snapshots only show the allocated memory. The stack traces that are below the massif threshold will be regrouped together (i.e. no detail is given for the stack traces below the thresholds).
The xtree requested with --xtree-memory=full contains 6 different detailed snapshots, giving the currently allocated bytes/blocks, the total allocated bytes/blocks, the total freed bytes/blocks. There is no threshold filtering for this xtree report, and so if your application has a lot of stack traces that are doing a small proportion of the alloc or free, you will have a lot more data in the massif xtree report than in the snapshots.
Instead of using a .ms format for the --xtree-memory-file, you might rather use the .kcg format, and examine it using kcachegrind : the kcachegrind format is more efficient to store huge amount of stack traces.
See http://www.valgrind.org/docs/manual/manual-core.html#manual-core.xtree for some more background information.