.root files in directory /tmp left over by TFileMerger

Dear Root Experts,

I have noticed that TFileMerger always leave at least one .root file in the directory /tmp upon usage.

I have attached two example .root files that I want to merge and macro merge.C that I used for merging. Files are merged perfectly well, but in /tmp directory there is always at least one file left over of the type:


Majority of those temporary files are removed correctly by root, but not all of them.

Question: Is there a way to force root to clean up all .root files from /tmp directory?

Thanks for any help,

P.S. ROOT 5.23/04 (tags/v5-23-04@28333, May 15 2009, 08:05:23 on linuxx8664gcc)
merge.C (202 Bytes)
file2.root (3.72 KB)
file1.root (3.71 KB)

Dear Root Experts,

I have meanwhile switched to

ROOT 5.24/00 (tags/v5-24-00@29258, Jul 01 2009, 12:22:53 on linuxx8664gcc)

but this problem still exists. Few sentences just to illustrate more clearly the problem:

1.) I want to use TFileMerger to merge a large amount of *.root files (~ 1 million files);

2.) It is impossible of course to add to TFileMerger in one go all those files, so I am merging them in cycles: in the first cycle I am adding first 100 files and I merge them and store in the file cycle1.root, then I reset TFileMerger and start the second cycle. At the beginning of second cycle I first add to TFileMerger the stored file cycle1.root and after it the next 100 files, and so on. Also, I am taking care than stored file from previous cycle is closed and deleted when I am progressing with the next cycle. In this way at once I have at maximum 101 files added in TFileMerger and this should work perfectly fine.

3.) But it doesn’t! The problem is that when I call at the and of the cycle:


the temporary *.root files created by TFileMerger in /tmp directory of the type


are not cleaned completely neither from the disk nor from the memory! More precisely: There is always AT LEAST one such file left over by TFileMerger both on disk and in memory per fileMerger->Merge() call. And as you can imagine, for 1000 cycles I am ending up with 1000 open files in memory and all the hell breaks loose. (I could figure out how to remove them ‘manually’ from the disk at the end of the cycle, but I couldn’t figure out how to close them ‘manually’ in memory at the end of the cycle…)

4.) I have attached again macro merge.C (I have added only call to Reset() method when compared to previous version I posted) with two *.root files that I want to merge and snapshot.png.

5.) Any help how to resolve this issue with TFileMerger is more than welcome.

6.) Alernatively, perhaps somebody could suggest another approach how to merge a larger number of *.root files (which in general contains TLists containing histograms and profiles).


file2.root (3.72 KB)
file1.root (3.71 KB)
merge.C (224 Bytes)