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

From: Pierre-Luc Drouin <pldrouin_at_physics.carleton.ca>
Date: Mon, 16 Apr 2007 15:38:21 -0400


Hi,

I try to delete all the TTree and TH objects from memory and their associated keys in the TFile using TDirectory::RecursiveRemove(TObject *) and TFile::Delete(char*) respectively. Do you mean that TDirectory::RecursiveRemove(TObject *obj) will not remove obj from memory but only from the TDirectory?

Thanks

Philippe Canal wrote:
> Hi Pierre-Luc,
>
> The RAM should not grow unless you require it. Note that removing the
> object from the file does __not__ remove it from memory. To help any
> further I would need to get a bit more details on what you actually do.
>
> Cheers,
> Philippe.
>
> PS. Also why is the code creating thousands of TTrees, this seems unusual.
>
> -----Original Message-----
> From: owner-roottalk_at_pcroot.cern.ch [mailto:owner-roottalk_at_pcroot.cern.ch]
> On Behalf Of Pierre-Luc Drouin
> Sent: Friday, April 13, 2007 7:31 PM
> To: Philippe Canal; roottalk_at_pcroot.cern.ch
> Subject: Re: [ROOT] How can I clean the memory used by deleted objects in a
> TFile/TDirectory?
>
> I have noticed the same problem with RAM memory before I close the
> TFile. Even if I delete these objects (TH, TTree), the memory used by
> the process continues to increase. Is it normal too? The code creates
> many thousands of TTrees and TH objects, so it can fill the whole RAM of
> the machine quite easily...
>
> Thanks
> Pierre-Luc Drouin
>
> Philippe Canal wrote:
>
>> 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 Drouin80
>> 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 Mon Apr 16 2007 - 21:38:40 CEST

This archive was generated by hypermail 2.2.0 : Mon Apr 16 2007 - 23:50:01 CEST