I am testing a small chunk of my code (C++ macro), which looks like:
void Function() {
TFile *openFile = new TFile("somefile.root", "READ");
TTree *dataTree = (TTree*) openFile->Get("some data");
store data from dataTree into vectors
delete openFile;
//2D_PDF is a class that contains two coordinate vectors of double and one 2-index vector of double (technically, vector < vector >
create an instance of 2D_PDF from the vectors above
for (iterate over "a pair of pairs of indices," so 4 indices that are i_x, i_y and j_x, j_y)
double xi = PDF.coord1[i_x], yi = PDF.coord2[i_y], wi = PDF.weight[i_x][i_y];
double xj = PDF.coord1[j_x], yj = PDF.coord2[j_y], wj = PDF.weight[j_x][j_y];
do some calculations with these variables
print some result statements
}
So, I am basically constructing a 2-dimensional probability density function out of data from a TTree in my .root data file and running some calculations for each pair of “square cells (i and j)” in the 2D PDF.
The code exits properly (successfully prints out the very last line of the code), but gives me:
*** Error in `/home/scheong/Desktop/root-6.06.02/bin/root.exe’: free(): invalid size: 0x0000000003fcc910 ***
in the end, and exits the root session (I am running the macro by .x Function.C).
This seems to be an error with the root built to my computer, not within the C++ macro itself, so I am not sure where to look to fix this. I just deleted root and re-installed it, yet the problem persists.
What is the problem? Is it something with the root build/setup, or is this an error with my code? I am suspecting it is the former, since the for loop I am running is fairly simple, and I cannot find any memory error (which is what free(): invalid size: seems to imply) in my loop.