Deleting a TKey from a TFile

From: Lee, Kerry T. \(JSC-SF\)[UHCL] <kerry.t.lee_at_nasa.gov>
Date: Thu, 11 May 2006 13:04:01 -0500


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 Thu May 11 2006 - 20:13:11 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET