Following this, I wrapped my functions with CALLGRIND_xxx_INSTRUMENTATION macros. However, I always get "out of memory".
Here is a simplified version of my program and callgrind would still run out of memory even though I could run callgrind without using the macros.
#include <cstdio>
#include <valgrind/callgrind.h>
void foo(int i)
{
  printf("i=%d\n", i);
}
int main()
{
   for (int i=0; i<1048576; i++)
   {
     CALLGRIND_START_INSTRUMENTATION;
     foo(i);
     CALLGRIND_STOP_INSTRUMENTATION;
   }
}
To run this, "valgrind --tool=callgrind --instr-atstart=no ./foo >foo.out".
Did I do anything wrong? Please help. Thanks!
 
    