Re: Pb. when delete pointer to TTree

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sat Nov 08 1997 - 16:42:32 MET


Laurent Aphecetche wrote:

> Hi,
>
> Owing the following "program" :
>
> file = new TFile...
> tree = new TTree("EM","EM particles",1000000) ;
> gEvent = new RBEvent ;
> b = tree->Branch("event","RBEvent",&gEvent,20000,1) ;
>
> ...
>
> tree->Write() ;
> file->Close() ;
> delete file ;
> delete b ;
> delete tree ;
> delete gEvent ;
>
> I got a SEGV on the delete b.
> Is there a special way (or order) to delete pointers on branches or
> trees.


When you close a file, histograms and Trees created on this file
disappear from memory as well.
You do not  need to delete branchs and trees.
Remove the two statements
    delete b;
    delete tree;
otherwise your program will crash because you attempt to delete
an object twice.

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:26:22 MET