I was just wondering if root deletes objects that are created on the heap.
When I write code for root, I usually do something like
void someFunction{
TH1D* hist = new TH1D(...);
hist->Fill(...);
hist->Draw();
// no delete hist !!
}
because I want to see the histogram on the screen, i.e. it should survive beyond the scope of the function. I also usually never delete my histograms. Is this wrong?
Or is this histogram properly deleted at some point? When?
Would it be better to write
void someFunction{
TH1D* hist = new TH1D(...);
hist->Fill(...);
hist->DrawCopy();
delete hist;
}
?
Related to this question, I found this: root.cern.ch/root/html534/guide … rship.html but I am missing an example to really understand the consequences of object ownership in root.