Unexpected Destructor Calls

Hi, I’m trying to optimize my code to run faster, and callgrind is revealing thousands of calls to a class Destructor. These are completely unexpected, as I only allocate these objects a few times in the program, and their lifetime is supposed to be quite long. I’m wondering if an expert with more ability in decyphering callgrind output can assist.

I’ve attached the output of callgrind_annotate --auto=yes, gzipped because it’s quite lengthy.

I’ve also used kcachegrind to look at the analysis, it seems to be correct: MyInterpolator::~MyInterpolator is called many times by inside different functions (including ROOT library functions). This leads me to think that it’s ROOT’s garbage collection at play?

Thanks, if I need to provide other information about my code, I can definitely do that. Unfortunately a “minimal example” will probably not be possible.

annotated_callgrind.txt.gz (1.32 MB)


Can you attach a regular callgrind output? valgrind --tool=callgrind --dump-every-bb=30000000 … should do.


I couldn’t attach it to the forum because there is a file size limit. I’ve instead uploaded it here: http://www.phas.ubc.ca/~jfcaron/callgrind.out.8125.tar.gz

The places where the t2x::MyInterpolator::~MyInterpolator() calls are happening seem to be non-deterministic. They just sort of show up everywhere…

Thanks for taking a look,


Yes, something is broken; valgrind thinks that R__unzip calls textinput (i.e. the prompt handling). Wrong.

Is this on MacOS? (I see MachO being mentioned.) valgrind doesn’t really work on MacOS. Please repeat on Linux and send the output - that should make more sense. Or use the XCode Profiler and send a sample file.

Cheers, Axel.

Yes this is on OSX. I knew valgrind didn’t work on 10.9 until recently, but with the latest versions it would install even through my package manager. I didn’t realize it was installable but not really working properly.

I redid the profiling with the XCode “instruments” program, and indeed the spurious calls are gone, so I’m guessing they were never really there in the first place. I was able to track down some minor memory leaks and further optimize my program.

Thanks for pointing me in the right direction.