Hi Glenn,
If you want to rewrite the same object, with the same key, do:
v.Write("vector",TObject::kOverwrite);
If you use f.Delete("*;*"), the space that you free can only be reused
when you reopen the file again. This is to guarantee directory
consistency.
Rene Brun
On Wed, 2 Feb 2000, Glen R. Salo wrote:
> Is there a way to delete objects from a TFile and free up the disk memory? The
> example given below illustrates the problem - even though I delete the TVector
> object, the size of the file does not decrease, and if I write the TVector to
> the file again, the file grows in size.
>
> Thanks for your help,
>
> Glen
>
> root [0] TFile f("test.root","RECREATE");
> root [1] f.ls();
> TFile** test.root
> TFile* test.root
> root [2] .!ls -l test.root
> -rw-r--r-- 1 gsalo gsalo 148 Feb 2 12:30 test.root
> root [3] TVector v(1000);
> root [4] v.Write("vector");
> root [5] f.ls();
> TFile** test.root
> TFile* test.root
> KEY: TVector vector;1 Vector class
> root [6] .!ls -l test.root
> -rw-r--r-- 1 gsalo gsalo 250 Feb 2 12:30 test.root
> root [7] f.Delete("*;*");
> root [8] f.ls();
> TFile** test.root
> TFile* test.root
> root [9] .!ls -l test.root
> -rw-r--r-- 1 gsalo gsalo 252 Feb 2 12:30 test.root
> root [10] v.Write("vector");
> root [11] f.ls();
> TFile** test.root
> TFile* test.root
> KEY: TVector vector;1 Vector class
> root [12] .!ls -l test.root
> -rw-r--r-- 1 gsalo gsalo 350 Feb 2 12:31 test.root
>
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:18 MET