Hello, all
//how to compile : g++ -o test test.cc `root-config --cflags --libs`
#include "TFile.h"
#include "TTree.h"
unsigned int pid, sid, tof, pl, pr, epoch;
int main()
{
TFile* rootfile = new TFile("test.root", "recreate");
TTree* roottree = new TTree("EventTree", "DC-TOF Event Data");
roottree->Branch("pid", &pid, "pid/i");
roottree->Branch("sid", &sid, "sid/i");
roottree->Branch("tof", &tof, "tof/i");
roottree->Branch("pl", &pl, "pl/i");
roottree->Branch("pr", &pr, "pr/i");
roottree->Branch("epoch", &epoch, "epoch/i");
pid=sid=tof=pl=pr=epoch=100;
while(true) {
roottree->Fill();
}
roottree->Write();
rootfile->Close();
}
With the above code, I monitored the memory usage of it using ‘top -p [pid of test]’.
It continued to increase its memory slowly so that it was crashed eventually.
I suspect TTree::Fill(). Is it normal? Or, is there any solution?
I would like to use TTree in my DAQ program running for long time.