Hello,
I’m trying to use Proof to run a reweighing fit on a 2-dimensional Histogram.
Now I have to call Process several times on the same tree (in my fcn-function for Minuit) to do that. But the histogram I fill with the Proof-Process causes a memory leak of several megabyte, so that the program crashes once it runs out of memory.
Attached are my TSelector and a small program that causes the memory leak. (Instead of minuit I just call the process in a loop).
Program, compiles or runs in root
memleak.C
[code]#include “getProof.C”//This is the getProof.C from the tutorial, was //the easiest way to get Proof to work for me
#include <TChain.h>
#include <TH2D.h>
#include <TCanvas.h>
TProof *proof;
TChain *chain;
void memleak();
int main() {
memleak();
}
void memleak() {
//Start up proof
TString tutdir = “/tmp/sailer”;
if (gSystem->AccessPathName(tutdir)) {
Printf(“runProof: creating the temporary directory”
" for the tutorial (%s) … “, tutdir.Data());
if (gSystem->mkdir(tutdir, kTRUE) != 0) {
Printf(“runProof: could not assert / create the temporary directory”
" for the tutorial (%s)”, tutdir.Data());
return;
}
}
proof = getProof(“proof://localhost:11093”, -1, tutdir.Data(), “restart”);
chain = new TChain(“T”);
chain->Add("/tmp/sailer/fit2corrected.root");
chain->SetProof();
for(Int_t k = 0; k < 5; k++){
chain->Process(“leaksel.C+”);
}
gSystem->Exit(0);
return;
}[/code]
leaksel.C
[code]
#define leaksel_cxx
#include “leaksel.h”
#include <TH2.h>
void leaksel::Begin(TTree * /tree/)
{
}
void leaksel::SlaveBegin(TTree * /tree/)
{
temp2d = new TH2D(“h2”,“prediction”, 1000, 0.6, 1.003, 1000, 0.6, 1.001);
fOutput->Add(temp2d);
}
Bool_t leaksel::Process(Long64_t entry)
{
fChain->GetEntry(entry);
temp2d->Fill(scaltree, srectree);
return kTRUE;
}
void leaksel::SlaveTerminate()
{
//This prevents memory leak, but then I can’t analyse in Terminate
//delete temp2d;
}
void leaksel::Terminate()
{
//Analyse temp2d here, calculate chi2 with other histogram coming as
//input
//temp2d = (TH2D*)fOutput->FindObject(“h2”);
}[/code]
Thanks in Advance,
André
leaksel.h (3.13 KB)