From d8330abbf06b0be5b45bd99f9c7e8fbb9486f025 Mon Sep 17 00:00:00 2001 From: ferdymercury Date: Tue, 26 Mar 2024 15:18:05 +0100 Subject: [PATCH] [hadd] avoid large RAM in hadd with multiple subdirs Fixes https://github.com/root-project/root/issues/13531 --- io/io/src/TFileMerger.cxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io/io/src/TFileMerger.cxx b/io/io/src/TFileMerger.cxx index e49daac3f5908..2972643b7d705 100644 --- a/io/io/src/TFileMerger.cxx +++ b/io/io/src/TFileMerger.cxx @@ -580,6 +580,8 @@ Bool_t TFileMerger::MergeOne(TDirectory *target, TList *sourcelist, Int_t type, // If this folder is a onlyListed object, merge everything inside. if (onlyListed) type &= ~kOnlyListed; status = MergeRecursive(newdir, sourcelist, type); + // Delete newdir directory after having written it (merged) + if (!(type&kIncremental)) delete newdir; if (onlyListed) type |= kOnlyListed; if (!status) return kFALSE; } else if (!cl->IsTObject() && cl->GetMerge()) {