Can't find cause of memory resident warning


I can’t seem to find the cause of the “memory resident” warnings that I get when accessing a TTree via TMVA.
I’ll outline my process for making the trees.
I have access to TTrees that store values as vectors. I convert these trees to normal TTrees, so that they can be accessed in TMVA. The vector trees are split into many files, so I first create a TChain, and then loop over this to write the new tree. Before any new TTrees are created I always create the relevant TFile, so I don’t know why I’m getting this error…

If anyone could look over the example code and point out my error, I would be greatly appreciative!!

char *name = new char[100];
TChain* Tree   = new TChain("Track_Tree");

TFile *file1;
TList *list1;
TH1D *Th1;
TFile *nfile1;

for (int i= 1; i<=95; i++){ 
    file1= TFile::Open(name,"");
    list1 = (TList*)file1->Get("output");
    Tree1 = (TTree*)list1->FindObject("Track_Tree"); 
    Th1 = (TH1D*)list1->FindObject("h1");
    nfile1= TFile::Open(name,"RECREATE");

    file1->Close(); //Added
    delete Tree1; //Added
    delete file1; //Added
    delete nfile1; //Added

TFile *outfile= TFile::Open("AnalysisResults_chain.root","RECREATE");
nTree = new TTree("Tracks","Tracks");   

vector<Double_t> *ptv; 
TBranch *ptbr = Tree->Branch("pt",&ptv);
Double_t temppt ;
TBranch *ptnbr = nTree->Branch("pt", &temppt);
   //write Vectors into Branches 
   for (int e=0; e<Tree->GetEntries(); e++) {
	   for (int k=0;k<ptv->size();k++){

Post here the output of:
echo “_file0->ls();” | root -b -n pathToFiles/_1.root
Or even better, attach here the “pathToFiles/_1.root” file.


I omitted that I used the “hadd” command to merge many small files into the larger ones before the TChain step.
The linked file is one of the smaller files before hadd. I hope this doesn’t change anything.
Link: … .root?dl=0


merge.cxx (1.34 KB)

Hi Pepe,

I adapted it to copy my full trees, and everything now runs without those memory resident warnings.
Thank you so much for your help :smiley:

So, after moving the file to another folder the warning messages came back.
I remade the file with the solution from above, however now the warning is there from the start. Is there anything that could explain this behaviour? :cry:

Attach your script for inspection.

Hi, … e.cxx?dl=0


merge.cxx (8.29 KB)

Hi Pepe,

So the problem still persists. Could it be that the data itself is somehow corrupted as it only gives the following error for some entries. This is a sample of the warning output when trying to read the Tree into TMVA.

Error in <TTree::Fill>: Failed filling branch:trackTree.phi, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.vertx, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.verty, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.vertz, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.MCpt, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.MCeta, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.MCphi, nbytes=-1, entry=1055510
Error in <TTree::Fill>: Failed filling branch:trackTree.nITSshared, nbytes=-1, entry=1055573
 This error is symptomatic of a Tree created as a memory-resident Tree
 Instead of doing:
    TTree *T = new TTree(...)
    TFile *f = new TFile(...)
 you should do:
    TFile *f = new TFile(...)
    TTree *T = new TTree(...)


Can it be that your disk is full, or that you exceed your disk quota or that you have no permission to write to that disk subdirectory at all?


I’m running all this locally, so it shouldn’t be a permission issue. I also have 70gB free, so I don’t think its a disk issue… :cry: