Re: [ROOT] TFile::Close

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Dec 23 2003 - 14:39:50 MET


Hi Christian,

You should "delete file" as soon as you have finished working
with a file to release all associated resources. Deleting a file
automatically closes the file. You do not need to Close and delete.
You can call Close if you plan to reuse the same file in the same 
program (calling Init again).

Rene Brun

On Tue, 
23 
Dec 2003, cstrato wrote:

> Dear Rooters, Merry Christmas
> 
> Sorrowly, I do not quite understand the difference
> between "delete myfile" and "myfile->Close()".
> 
> When do you usually call "myfile->Close()"?
> When do you usually delete a TFile?
> 
> Looking at the source code, both TFile destructor and
> TFile::Close() contain the following line:
>     gROOT->GetListOfFiles()->Remove(this);
> This means that when I close the file, I can no longer
> access it with GetListOfFiles(), although it is not
> deleted. Does this mean that I have to delete the file
> myself, when I call Close() because CleanUpROOTAtExit()
> can no longer delete it?
> 
> The reason of asking is that from my GUI app I can
> open lots of TFiles, and the question is whether I
> should keep all files open during the life of my
> program or if I should close/delete a TFile when I
> do no longer need it?
> 
> Thank you in advance
> Best regards
> Christian
> _._._._._._._._._._._._._._._._
> C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
> V.i.e.n.n.a       A.u.s.t.r.i.a
> _._._._._._._._._._._._._._._._
> 



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET