I just started getting in touch with Valgrinds massif tool and wanted to know, if one could introduce a checkpoint to start monitoring the heap allocation.
Considering the following basic example:
#include <iostream>
int main()
{
int nrOfElements= 10;
uint32_t *a[nrOfElements];
for(int i=0; i<nrOfElements; i++)
{
a[i] = new uint32_t(i);
}
return 0;
}
compiling it, running valgrind (valgrind --tool=massif --time-unit=B ./program) and executing ms_print massif.out.3***** returns the following memory table :
here we can see, that there is an initial heap memory allocation from the standard library of 72,704 Bytes. Since I am only interested in the memory allocation starting from the main, I was wondering how i could do that? Is there something like a checkpoint, which one could introduce to monitor the memory allocation only in a certain area?
Massif doesn't have a mechanism to turn instrumentation on and off.
Take a look at the --ignore-fn=
option, and specifically for your example --ignore-fn=call_init.part.0
. You can repeat use of this option to filter out multiple functions.