Memory Increases when using TTree->Draw()

Dear Rooters,

According to the TCutG tutorial, I can create a TCutG object and provide the name of TCutG object as a “selection” string for

TCutG *cutg = new TCutG(“mycutg”,5);
cutg->SetVarX(“y”);
cutg->SetVarY(“x”);
cutg->SetPoint(0,-0.3586207,1.509534);
cutg->SetPoint(1,-1.894181,-0.529661);
cutg->SetPoint(2,0.07780173,-1.21822);
cutg->SetPoint(3,-1.0375,-0.07944915);
cutg->SetPoint(4,0.756681,0.1853814);
cutg->SetPoint(5,-0.3586207,1.509534);

TTree->Draw(“x:y”, “mycutg”, “goff”).

But if I keep using Draw with the selection string of “mycutg” many times, the memory will continue increasing unboundedly. The memory increase will only stop when I set the selection string as empty “”. I am wondering whether this is a bug in TTree->Draw() function.

Thank you very much for your suggestion!

Hi,

Which version of ROOT are you using? A memory leak related to the use of TCutG has been fixed in v5.28.

Cheers,
Philippe.

Hi Philippe,

I just saw your reply. I am working with v5.27/06. I use the changed code SetObjectX() and SetObjectY() in tcutg.cxx file and the memory leak is fixed.

Thank you so much for your advice! This problem has bothered me for a while :slight_smile:

Cheers~