RE: How can I clean the memory used by deleted objects in a TFile/TDirectory?

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Fri, 13 Apr 2007 12:57:43 -0500


Hi Pierre-Luc,

When you 'delete' an object from a ROOT file, it does not reduce the size of the file. Instead, the add the newly 'freed' file area to a list of 'empty space' in the file. This list is first search when writing another object to the file to see if one of the space will be able to hold it. 'Compacting' the file to remove to empty space would require to shift the bit around on the disk (aka an expansive operation). The easiest to compact a ROOT file is simply to create a new file and copy the object to the new files. Since you have only histogram and tree, you can use hadd to do this copy.

Cheers,
Philippe.

-----Original Message-----
From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch] On Behalf Of Pierre-Luc Drouin
Sent: Thursday, April 12, 2007 11:17 AM
To: roottalk_at_pcroot.cern.ch
Subject: [ROOT] How can I clean the memory used by deleted objects in a TFile/TDirectory?

Hi,

I have some code that creates and then deletes many objects and (TH, TTree, TDirectory) in a ROOT file and that saves this file with only a few remaining objects. When I reopen the ROOT file I see only the TKeys of the few objects that I have not deleted, but the size of the file is way too big for these objects (it looks like that some previously deleted objects are still using space) . I would like to know how could I clean efficiently the ROOT file. I am using ROOT 5.14/00c. I delete the objects in memory using TDirectory::RecursiveRemove(TObject*) and the TKeys using TDirectory::Delete(char *).

Thanks
Pierre-Luc Drouin Received on Fri Apr 13 2007 - 19:58:25 CEST

This archive was generated by hypermail 2.2.0 : Sat Apr 14 2007 - 05:50:01 CEST