Is it necessary to delete Clone() object?

Hi,
I have a line:
histos[0]= (TH1F*)gDirectory->Get(“name”)->Clone();
in a loop in my program, is it necessary to do a ‘delete’ for ‘histos[0]’ ? ‘histos[0]’ is global scopes.
I do delete in the following way at the beginning of each loop:
if(histos[0] != NULL)
{
histos[0]->Delete(); // “delete histos[0]” is better or the same?
histos[0] = NULL;
}
my program is compiled via ACLiC.

Thank you!

Hi,

If you no longer need this histogram there is no harm in deleting it via:delete histo[0];whether it is necessary depends on whether it is attached to a directory or not (which it would if gDirectory is not null and you did not call TH1::AddHistogram(0)) ; If the histo is attached to a directory, the directory will delete it (unless you delete it first).

Cheers,
Philippe.