What you see is the expected behaviour. The gap left in the file when
deleting an object will only be reused if you close and reopen the file.
This is done on purpose to support the case of multiple readers accessing
a file written by another process.
Rene Brun
On
Thu, 11 May 2006, Lee, Kerry T. (JSC-SF)[UHCL] wrote:
> Dear ROOT team,
>
> I am using ROOT 5.11/02 compiled on a linux machine with gcc 3.4.4.
>
> I am attempting to delete a TKey within a TFile, but it does not reduce the size of the file as I would expect. Below is a couple short examples to illustrate what I see.
>
>
> root [0] TFile *f = new TFile("testing2.root","RECREATE");
> root [1] f->Write();
> root [2] f->Close();
> root [3] .q
>
> the size of the file is then 330 bytes as shown below
>
> [kerrylee_at_jsc-sf-2148872 ~]$ ls -l testing2.root
> -rw-r--r-- 1 kerrylee kerrylee 330 May 11 12:44 testing2.root
>
> Now if I write an empty TTree to a file.
>
> root [0] TFile *f = new TFile("testing.root","RECREATE");
> root [1] TTree *t = new TTree("TestTree","This is a test");
> root [2] f->Write();
> root [3] f->Close();
> root [4] .q
> [kerrylee_at_jsc-sf-2148872 ~]$ ls -l testing.root
> -rw-r--r-- 1 kerrylee kerrylee 4223 May 11 12:53 testing.root
>
> Then try to delete the tree. I do not see a change in the file size even though ls() shows that the TTree as being deleted.
>
> root [0] TFile *f = new TFile("testing.root","UPDATE");
> root [1] f->ls();
> TFile** testing.root
> TFile* testing.root
> KEY: TTree TestTree;1 This is a test
> root [2] f->Delete("TestTree;1");
> root [3] f->Flush();
> root [4] f->ls()
> TFile** testing.root
> TFile* testing.root
> root [5] f->Close();
> root [6] .q
> [kerrylee_at_jsc-sf-2148872 ~]$ ls -l testing.root
> -rw-r--r-- 1 kerrylee kerrylee 4223 May 11 12:55 testing.root
>
>
> I would expect that the updated file should be 330 bytes. Have I misunderstood how to remove a TKey properly?
>
> Thanks
> Kerry
>
>
>
>
Received on Fri May 12 2006 - 07:11:12 MEST
This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET